@@ -116,7 +116,7 @@ export type ExecutionResult = {
116
116
*/
117
117
export type ExecutionPartialResult < T > = MaybePromise < {
118
118
errors ?: $ReadOnlyArray < GraphQLError > ,
119
- data ?: MaybePromise < T | null > ,
119
+ data ?: T | null ,
120
120
} > ;
121
121
122
122
export type ExecutionArgs = { |
@@ -265,20 +265,12 @@ function buildResponse(
265
265
context : ExecutionContext ,
266
266
result : ExecutionPartialResult < mixed > ,
267
267
) {
268
- const resultpromise = getPromise ( result ) ;
269
- if ( resultpromise ) {
270
- return resultpromise . then ( resolved =>
268
+ const promise = getPromise ( result ) ;
269
+ if ( promise ) {
270
+ return promise . then ( resolved =>
271
271
buildResponse ( context , mergeErrors ( context , resolved ) ) ,
272
272
) ;
273
273
}
274
- if ( result . data ) {
275
- const promise = getPromise ( result . data ) ;
276
- if ( promise ) {
277
- return promise . then ( resolveddata =>
278
- buildResponse ( context , mergeErrors ( context , { data : resolveddata } ) ) ,
279
- ) ;
280
- }
281
- }
282
274
if ( result . data && ( ! result . errors || ! result . errors . length ) ) {
283
275
return { data : result . data } ;
284
276
}
@@ -1110,7 +1102,7 @@ function completeListValue(
1110
1102
} ) ;
1111
1103
1112
1104
return containsPromise
1113
- ? { data : Promise . all ( completedResults ) }
1105
+ ? Promise . all ( completedResults ) . then ( data => ( { data } ) )
1114
1106
: { data : completedResults } ;
1115
1107
}
1116
1108
@@ -1246,16 +1238,19 @@ function completeObjectValue(
1246
1238
if ( ! isTypeOfResult ) {
1247
1239
throw invalidReturnTypeError ( returnType , result , fieldNodes ) ;
1248
1240
}
1249
- return {
1250
- data : collectAndExecuteSubfields (
1251
- exeContext ,
1252
- returnType ,
1253
- fieldNodes ,
1254
- info ,
1255
- path ,
1256
- result ,
1257
- ) ,
1258
- } ;
1241
+ const data = collectAndExecuteSubfields (
1242
+ exeContext ,
1243
+ returnType ,
1244
+ fieldNodes ,
1245
+ info ,
1246
+ path ,
1247
+ result ,
1248
+ ) ;
1249
+ const subpromise = getPromise ( data ) ;
1250
+ if ( subpromise ) {
1251
+ return subpromise . then ( d => ( { data : d } ) ) ;
1252
+ }
1253
+ return { data } ;
1259
1254
} ) ;
1260
1255
}
1261
1256
@@ -1264,16 +1259,19 @@ function completeObjectValue(
1264
1259
}
1265
1260
}
1266
1261
1267
- return {
1268
- data : collectAndExecuteSubfields (
1269
- exeContext ,
1270
- returnType,
1271
- fieldNodes,
1272
- info,
1273
- path,
1274
- result,
1275
- ) ,
1276
- } ;
1262
+ const subfields = collectAndExecuteSubfields (
1263
+ exeContext ,
1264
+ returnType,
1265
+ fieldNodes,
1266
+ info,
1267
+ path,
1268
+ result,
1269
+ ) ;
1270
+ const subfpromise = getPromise ( subfields ) ;
1271
+ if ( subfpromise ) {
1272
+ return subfpromise . then ( d => ( { data : d } ) ) ;
1273
+ }
1274
+ return { data : subfields } ;
1277
1275
}
1278
1276
1279
1277
function invalidReturnTypeError (
0 commit comments