@@ -1107,19 +1107,17 @@ async function completeAsyncIteratorValue(
11071107 /* c8 ignore start */
11081108 if ( isPromise ( item ) ) {
11091109 completedResults . push (
1110- completePromisedValue (
1110+ completePromisedListItemValue (
1111+ item ,
1112+ graphqlWrappedResult ,
11111113 exeContext ,
11121114 itemType ,
11131115 fieldGroup ,
11141116 info ,
11151117 itemPath ,
1116- item ,
11171118 incrementalContext ,
11181119 deferMap ,
1119- ) . then ( ( resolved ) => {
1120- graphqlWrappedResult [ 1 ] . push ( ...resolved [ 1 ] ) ;
1121- return resolved [ 0 ] ;
1122- } ) ,
1120+ ) ,
11231121 ) ;
11241122 containsPromise = true ;
11251123 } else if (
@@ -1232,19 +1230,17 @@ function completeListValue(
12321230
12331231 if ( isPromise ( item ) ) {
12341232 completedResults . push (
1235- completePromisedValue (
1233+ completePromisedListItemValue (
1234+ item ,
1235+ graphqlWrappedResult ,
12361236 exeContext ,
12371237 itemType ,
12381238 fieldGroup ,
12391239 info ,
12401240 itemPath ,
1241- item ,
12421241 incrementalContext ,
12431242 deferMap ,
1244- ) . then ( ( resolved ) => {
1245- graphqlWrappedResult [ 1 ] . push ( ...resolved [ 1 ] ) ;
1246- return resolved [ 0 ] ;
1247- } ) ,
1243+ ) ,
12481244 ) ;
12491245 containsPromise = true ;
12501246 } else if (
@@ -1334,6 +1330,41 @@ function completeListItemValue(
13341330 return false ;
13351331}
13361332
1333+ async function completePromisedListItemValue (
1334+ item : unknown ,
1335+ parent : GraphQLWrappedResult < Array < unknown > > ,
1336+ exeContext : ExecutionContext ,
1337+ itemType : GraphQLOutputType ,
1338+ fieldGroup : FieldGroup ,
1339+ info : GraphQLResolveInfo ,
1340+ itemPath : Path ,
1341+ incrementalContext : IncrementalContext | undefined ,
1342+ deferMap : ReadonlyMap < DeferUsage , DeferredFragmentRecord > | undefined ,
1343+ ) : Promise < unknown > {
1344+ try {
1345+ const resolved = await item ;
1346+ let completed = completeValue (
1347+ exeContext ,
1348+ itemType ,
1349+ fieldGroup ,
1350+ info ,
1351+ itemPath ,
1352+ resolved ,
1353+ incrementalContext ,
1354+ deferMap ,
1355+ ) ;
1356+ if ( isPromise ( completed ) ) {
1357+ completed = await completed ;
1358+ }
1359+ parent [ 1 ] . push ( ...completed [ 1 ] ) ;
1360+ return completed [ 0 ] ;
1361+ } catch ( rawError ) {
1362+ const errors = ( incrementalContext ?? exeContext ) . errors ;
1363+ handleFieldError ( rawError , itemType , fieldGroup , itemPath , errors ) ;
1364+ return null ;
1365+ }
1366+ }
1367+
13371368/**
13381369 * Complete a Scalar or Enum by serializing to a valid value, returning
13391370 * null if serialization is not possible.
0 commit comments