@@ -1101,19 +1101,17 @@ async function completeAsyncIteratorValue(
11011101 /* c8 ignore start */
11021102 if ( isPromise ( item ) ) {
11031103 completedResults . push (
1104- completePromisedValue (
1104+ completePromisedListItemValue (
1105+ item ,
1106+ graphqlWrappedResult ,
11051107 exeContext ,
11061108 itemType ,
11071109 fieldGroup ,
11081110 info ,
11091111 itemPath ,
1110- item ,
11111112 incrementalContext ,
11121113 deferMap ,
1113- ) . then ( ( resolved ) => {
1114- graphqlWrappedResult [ 1 ] . push ( ...resolved [ 1 ] ) ;
1115- return resolved [ 0 ] ;
1116- } ) ,
1114+ ) ,
11171115 ) ;
11181116 containsPromise = true ;
11191117 } else if (
@@ -1226,19 +1224,17 @@ function completeListValue(
12261224
12271225 if ( isPromise ( item ) ) {
12281226 completedResults . push (
1229- completePromisedValue (
1227+ completePromisedListItemValue (
1228+ item ,
1229+ graphqlWrappedResult ,
12301230 exeContext ,
12311231 itemType ,
12321232 fieldGroup ,
12331233 info ,
12341234 itemPath ,
1235- item ,
12361235 incrementalContext ,
12371236 deferMap ,
1238- ) . then ( ( resolved ) => {
1239- graphqlWrappedResult [ 1 ] . push ( ...resolved [ 1 ] ) ;
1240- return resolved [ 0 ] ;
1241- } ) ,
1237+ ) ,
12421238 ) ;
12431239 containsPromise = true ;
12441240 } else if (
@@ -1328,6 +1324,41 @@ function completeListItemValue(
13281324 return false ;
13291325}
13301326
1327+ async function completePromisedListItemValue (
1328+ item : unknown ,
1329+ parent : GraphQLWrappedResult < Array < unknown > > ,
1330+ exeContext : ExecutionContext ,
1331+ itemType : GraphQLOutputType ,
1332+ fieldGroup : FieldGroup ,
1333+ info : GraphQLResolveInfo ,
1334+ itemPath : Path ,
1335+ incrementalContext : IncrementalContext | undefined ,
1336+ deferMap : ReadonlyMap < DeferUsage , DeferredFragmentRecord > | undefined ,
1337+ ) : Promise < unknown > {
1338+ try {
1339+ const resolved = await item ;
1340+ let completed = completeValue (
1341+ exeContext ,
1342+ itemType ,
1343+ fieldGroup ,
1344+ info ,
1345+ itemPath ,
1346+ resolved ,
1347+ incrementalContext ,
1348+ deferMap ,
1349+ ) ;
1350+ if ( isPromise ( completed ) ) {
1351+ completed = await completed ;
1352+ }
1353+ parent [ 1 ] . push ( ...completed [ 1 ] ) ;
1354+ return completed [ 0 ] ;
1355+ } catch ( rawError ) {
1356+ const errors = ( incrementalContext ?? exeContext ) . errors ;
1357+ handleFieldError ( rawError , itemType , fieldGroup , itemPath , errors ) ;
1358+ return null ;
1359+ }
1360+ }
1361+
13311362/**
13321363 * Complete a Scalar or Enum by serializing to a valid value, returning
13331364 * null if serialization is not possible.
0 commit comments