@@ -1398,7 +1398,7 @@ function completeIterableValueWithPossibleStream(
1398
1398
*/
1399
1399
function completeListItemValue (
1400
1400
item : unknown ,
1401
- acc : GraphQLResult < Array < unknown > > ,
1401
+ parent : GraphQLResult < Array < unknown > > ,
1402
1402
index : number ,
1403
1403
promises : Array < Promise < unknown > > ,
1404
1404
exeContext : ExecutionContext ,
@@ -1409,6 +1409,7 @@ function completeListItemValue(
1409
1409
incrementalContext : IncrementalContext | undefined ,
1410
1410
deferMap : ReadonlyMap < DeferUsage , DeferredFragmentRecord > | undefined ,
1411
1411
) : void {
1412
+ const completedResults = parent [ 0 ] ;
1412
1413
try {
1413
1414
const completedItem = completeValue (
1414
1415
exeContext ,
@@ -1422,13 +1423,14 @@ function completeListItemValue(
1422
1423
) ;
1423
1424
1424
1425
if ( isPromise ( completedItem ) ) {
1426
+ completedResults . push ( undefined ) ;
1425
1427
// Note: we don't rely on a `catch` method, but we do expect "thenable"
1426
1428
// to take a second callback for the error case.
1427
1429
promises . push (
1428
1430
completedItem . then (
1429
1431
( resolved ) => {
1430
- acc [ 0 ] [ index ] = resolved [ 0 ] ;
1431
- appendNewIncrementalDataRecords ( acc , resolved [ 1 ] ) ;
1432
+ completedResults [ index ] = resolved [ 0 ] ;
1433
+ appendNewIncrementalDataRecords ( parent , resolved [ 1 ] ) ;
1432
1434
} ,
1433
1435
( rawError ) => {
1434
1436
handleFieldError (
@@ -1439,13 +1441,13 @@ function completeListItemValue(
1439
1441
itemPath ,
1440
1442
incrementalContext ,
1441
1443
) ;
1442
- acc [ 0 ] [ index ] = null ;
1444
+ completedResults [ index ] = null ;
1443
1445
} ,
1444
1446
) ,
1445
1447
) ;
1446
1448
} else {
1447
- acc [ 0 ] [ index ] = completedItem [ 0 ] ;
1448
- appendNewIncrementalDataRecords ( acc , completedItem [ 1 ] ) ;
1449
+ completedResults . push ( completedItem [ 0 ] ) ;
1450
+ appendNewIncrementalDataRecords ( parent , completedItem [ 1 ] ) ;
1449
1451
}
1450
1452
} catch ( rawError ) {
1451
1453
handleFieldError (
@@ -1456,13 +1458,13 @@ function completeListItemValue(
1456
1458
itemPath ,
1457
1459
incrementalContext ,
1458
1460
) ;
1459
- acc [ 0 ] . push ( null ) ;
1461
+ completedResults . push ( null ) ;
1460
1462
}
1461
1463
}
1462
1464
1463
1465
async function completePromisedListItemValue (
1464
1466
item : unknown ,
1465
- acc : GraphQLResult < Array < unknown > > ,
1467
+ parent : GraphQLResult < Array < unknown > > ,
1466
1468
index : number ,
1467
1469
exeContext : ExecutionContext ,
1468
1470
itemType : GraphQLOutputType ,
@@ -1472,6 +1474,8 @@ async function completePromisedListItemValue(
1472
1474
incrementalContext : IncrementalContext | undefined ,
1473
1475
deferMap : ReadonlyMap < DeferUsage , DeferredFragmentRecord > | undefined ,
1474
1476
) : Promise < void > {
1477
+ const completedResults = parent [ 0 ] ;
1478
+ completedResults [ index ] = undefined ;
1475
1479
try {
1476
1480
const resolvedItem = await item ;
1477
1481
let completed = completeValue (
@@ -1487,8 +1491,8 @@ async function completePromisedListItemValue(
1487
1491
if ( isPromise ( completed ) ) {
1488
1492
completed = await completed ;
1489
1493
}
1490
- acc [ 0 ] [ index ] = completed [ 0 ] ;
1491
- appendNewIncrementalDataRecords ( acc , completed [ 1 ] ) ;
1494
+ completedResults [ index ] = completed [ 0 ] ;
1495
+ appendNewIncrementalDataRecords ( parent , completed [ 1 ] ) ;
1492
1496
} catch ( rawError ) {
1493
1497
handleFieldError (
1494
1498
rawError ,
@@ -1498,7 +1502,7 @@ async function completePromisedListItemValue(
1498
1502
itemPath ,
1499
1503
incrementalContext ,
1500
1504
) ;
1501
- acc [ 0 ] [ index ] = null ;
1505
+ completedResults [ index ] = null ;
1502
1506
}
1503
1507
}
1504
1508
0 commit comments