@@ -1398,7 +1398,7 @@ function completeIterableValueWithPossibleStream(
13981398 */
13991399function completeListItemValue (
14001400 item : unknown ,
1401- acc : GraphQLResult < Array < unknown > > ,
1401+ parent : GraphQLResult < Array < unknown > > ,
14021402 index : number ,
14031403 promises : Array < Promise < unknown > > ,
14041404 exeContext : ExecutionContext ,
@@ -1409,6 +1409,7 @@ function completeListItemValue(
14091409 incrementalContext : IncrementalContext | undefined ,
14101410 deferMap : ReadonlyMap < DeferUsage , DeferredFragmentRecord > | undefined ,
14111411) : void {
1412+ const completedResults = parent [ 0 ] ;
14121413 try {
14131414 const completedItem = completeValue (
14141415 exeContext ,
@@ -1422,13 +1423,14 @@ function completeListItemValue(
14221423 ) ;
14231424
14241425 if ( isPromise ( completedItem ) ) {
1426+ completedResults . push ( undefined ) ;
14251427 // Note: we don't rely on a `catch` method, but we do expect "thenable"
14261428 // to take a second callback for the error case.
14271429 promises . push (
14281430 completedItem . then (
14291431 ( resolved ) => {
1430- acc [ 0 ] [ index ] = resolved [ 0 ] ;
1431- appendNewIncrementalDataRecords ( acc , resolved [ 1 ] ) ;
1432+ completedResults [ index ] = resolved [ 0 ] ;
1433+ appendNewIncrementalDataRecords ( parent , resolved [ 1 ] ) ;
14321434 } ,
14331435 ( rawError ) => {
14341436 handleFieldError (
@@ -1439,13 +1441,13 @@ function completeListItemValue(
14391441 itemPath ,
14401442 incrementalContext ,
14411443 ) ;
1442- acc [ 0 ] [ index ] = null ;
1444+ completedResults [ index ] = null ;
14431445 } ,
14441446 ) ,
14451447 ) ;
14461448 } else {
1447- acc [ 0 ] [ index ] = completedItem [ 0 ] ;
1448- appendNewIncrementalDataRecords ( acc , completedItem [ 1 ] ) ;
1449+ completedResults . push ( completedItem [ 0 ] ) ;
1450+ appendNewIncrementalDataRecords ( parent , completedItem [ 1 ] ) ;
14491451 }
14501452 } catch ( rawError ) {
14511453 handleFieldError (
@@ -1456,13 +1458,13 @@ function completeListItemValue(
14561458 itemPath ,
14571459 incrementalContext ,
14581460 ) ;
1459- acc [ 0 ] . push ( null ) ;
1461+ completedResults . push ( null ) ;
14601462 }
14611463}
14621464
14631465async function completePromisedListItemValue (
14641466 item : unknown ,
1465- acc : GraphQLResult < Array < unknown > > ,
1467+ parent : GraphQLResult < Array < unknown > > ,
14661468 index : number ,
14671469 exeContext : ExecutionContext ,
14681470 itemType : GraphQLOutputType ,
@@ -1472,6 +1474,8 @@ async function completePromisedListItemValue(
14721474 incrementalContext : IncrementalContext | undefined ,
14731475 deferMap : ReadonlyMap < DeferUsage , DeferredFragmentRecord > | undefined ,
14741476) : Promise < void > {
1477+ const completedResults = parent [ 0 ] ;
1478+ completedResults [ index ] = undefined ;
14751479 try {
14761480 const resolvedItem = await item ;
14771481 let completed = completeValue (
@@ -1487,8 +1491,8 @@ async function completePromisedListItemValue(
14871491 if ( isPromise ( completed ) ) {
14881492 completed = await completed ;
14891493 }
1490- acc [ 0 ] [ index ] = completed [ 0 ] ;
1491- appendNewIncrementalDataRecords ( acc , completed [ 1 ] ) ;
1494+ completedResults [ index ] = completed [ 0 ] ;
1495+ appendNewIncrementalDataRecords ( parent , completed [ 1 ] ) ;
14921496 } catch ( rawError ) {
14931497 handleFieldError (
14941498 rawError ,
@@ -1498,7 +1502,7 @@ async function completePromisedListItemValue(
14981502 itemPath ,
14991503 incrementalContext ,
15001504 ) ;
1501- acc [ 0 ] [ index ] = null ;
1505+ completedResults [ index ] = null ;
15021506 }
15031507}
15041508
0 commit comments