@@ -19,7 +19,7 @@ import memoize3 from '../jsutils/memoize3';
19
19
import promiseForObject from '../jsutils/promiseForObject' ;
20
20
import promiseReduce from '../jsutils/promiseReduce' ;
21
21
import type { ObjMap } from '../jsutils/ObjMap' ;
22
- import type { MaybePromise } from '../jsutils/MaybePromise ' ;
22
+ import type { PromiseOrValue } from '../jsutils/PromiseOrValue ' ;
23
23
24
24
import { getOperationRootType } from '../utilities/getOperationRootType' ;
25
25
import { typeFromAST } from '../utilities/typeFromAST' ;
@@ -144,7 +144,7 @@ export type ExecutionArgs = {|
144
144
declare function execute (
145
145
ExecutionArgs ,
146
146
..._ : [ ]
147
- ) : MaybePromise < ExecutionResult > ;
147
+ ) : PromiseOrValue < ExecutionResult > ;
148
148
/* eslint-disable no-redeclare */
149
149
declare function execute(
150
150
schema: GraphQLSchema,
@@ -155,7 +155,7 @@ declare function execute(
155
155
operationName?: ?string,
156
156
fieldResolver?: ?GraphQLFieldResolver< any , any > ,
157
157
typeResolver?: ?GraphQLTypeResolver< any , any > ,
158
- ): MaybePromise < ExecutionResult > ;
158
+ ): PromiseOrValue < ExecutionResult > ;
159
159
export function execute(
160
160
argsOrSchema,
161
161
document,
@@ -239,7 +239,7 @@ function executeImpl(
239
239
*/
240
240
function buildResponse (
241
241
exeContext : ExecutionContext ,
242
- data : MaybePromise < ObjMap < mixed > | null> ,
242
+ data : PromiseOrValue < ObjMap < mixed > | null> ,
243
243
) {
244
244
if ( isPromise ( data ) ) {
245
245
return data . then ( resolved => buildResponse ( exeContext , resolved ) ) ;
@@ -393,7 +393,7 @@ function executeOperation(
393
393
exeContext : ExecutionContext ,
394
394
operation : OperationDefinitionNode ,
395
395
rootValue : mixed ,
396
- ) : MaybePromise < ObjMap < mixed > | null> {
396
+ ) : PromiseOrValue < ObjMap < mixed > | null> {
397
397
const type = getOperationRootType ( exeContext . schema , operation ) ;
398
398
const fields = collectFields (
399
399
exeContext ,
@@ -438,7 +438,7 @@ function executeFieldsSerially(
438
438
sourceValue : mixed ,
439
439
path : ResponsePath | void ,
440
440
fields : ObjMap < Array < FieldNode > > ,
441
- ) : MaybePromise < ObjMap < mixed > > {
441
+ ) : PromiseOrValue < ObjMap < mixed > > {
442
442
return promiseReduce (
443
443
Object . keys ( fields ) ,
444
444
( results , responseName ) => {
@@ -477,7 +477,7 @@ function executeFields(
477
477
sourceValue: mixed,
478
478
path: ResponsePath | void,
479
479
fields: ObjMap< Array < FieldNode > > ,
480
- ) : MaybePromise < ObjMap < mixed > > {
480
+ ) : PromiseOrValue < ObjMap < mixed > > {
481
481
const results = Object . create ( null ) ;
482
482
let containsPromise = false ;
483
483
@@ -653,7 +653,7 @@ function resolveField(
653
653
source: mixed,
654
654
fieldNodes: $ReadOnlyArray< FieldNode > ,
655
655
path: ResponsePath,
656
- ): MaybePromise < mixed > {
656
+ ): PromiseOrValue < mixed > {
657
657
const fieldNode = fieldNodes [ 0 ] ;
658
658
const fieldName = fieldNode . name . value ;
659
659
@@ -766,7 +766,7 @@ function completeValueCatchingError(
766
766
info: GraphQLResolveInfo,
767
767
path: ResponsePath,
768
768
result: mixed,
769
- ): MaybePromise < mixed > {
769
+ ): PromiseOrValue < mixed > {
770
770
try {
771
771
let completed ;
772
772
if ( isPromise ( result ) ) {
@@ -844,7 +844,7 @@ function completeValue(
844
844
info: GraphQLResolveInfo,
845
845
path: ResponsePath,
846
846
result: mixed,
847
- ): MaybePromise < mixed > {
847
+ ): PromiseOrValue < mixed > {
848
848
// If result is an Error, throw a located error.
849
849
if ( result instanceof Error ) {
850
850
throw result ;
@@ -939,7 +939,7 @@ function completeListValue(
939
939
info: GraphQLResolveInfo,
940
940
path: ResponsePath,
941
941
result: mixed,
942
- ): MaybePromise < $ReadOnlyArray < mixed > > {
942
+ ): PromiseOrValue < $ReadOnlyArray < mixed > > {
943
943
invariant (
944
944
isCollection ( result ) ,
945
945
`Expected Iterable, but did not find one for field ${
@@ -1001,7 +1001,7 @@ function completeAbstractValue(
1001
1001
info: GraphQLResolveInfo,
1002
1002
path: ResponsePath,
1003
1003
result: mixed,
1004
- ): MaybePromise < ObjMap < mixed > > {
1004
+ ): PromiseOrValue < ObjMap < mixed > > {
1005
1005
const resolveTypeFn = returnType . resolveType || exeContext . typeResolver ;
1006
1006
const contextValue = exeContext . contextValue ;
1007
1007
const runtimeType = resolveTypeFn ( result , contextValue , info , returnType ) ;
@@ -1088,7 +1088,7 @@ function completeObjectValue(
1088
1088
info : GraphQLResolveInfo ,
1089
1089
path : ResponsePath ,
1090
1090
result : mixed ,
1091
- ) : MaybePromise < ObjMap < mixed >> {
1091
+ ) : PromiseOrValue < ObjMap < mixed >> {
1092
1092
// If there is an isTypeOf predicate function, call it with the
1093
1093
// current result. If isTypeOf returns false, then raise an error rather
1094
1094
// than continuing execution.
@@ -1141,7 +1141,7 @@ function collectAndExecuteSubfields(
1141
1141
fieldNodes : $ReadOnlyArray < FieldNode > ,
1142
1142
path : ResponsePath ,
1143
1143
result : mixed ,
1144
- ) : MaybePromise < ObjMap < mixed >> {
1144
+ ) : PromiseOrValue < ObjMap < mixed >> {
1145
1145
// Collect sub-fields to execute to complete this value.
1146
1146
const subFieldNodes = collectSubfields ( exeContext , returnType , fieldNodes ) ;
1147
1147
return executeFields ( exeContext , returnType , result , path , subFieldNodes ) ;
0 commit comments