@@ -1114,27 +1114,9 @@ async function completeAsyncIteratorValue(
1114
1114
break ;
1115
1115
}
1116
1116
1117
- const item = iteration . value ;
1118
- // TODO: add test case for asyncIterator returning a promise
1119
- /* c8 ignore start */
1120
- if ( isPromise ( item ) ) {
1121
- completedResults . push (
1122
- completePromisedListItemValue (
1123
- item ,
1124
- exeContext ,
1125
- itemType ,
1126
- fieldGroup ,
1127
- info ,
1128
- itemPath ,
1129
- incrementalContext ,
1130
- deferMap ,
1131
- ) ,
1132
- ) ;
1133
- containsPromise = true ;
1134
- } else if (
1135
- /* c8 ignore stop */
1117
+ if (
1136
1118
completeListItemValue (
1137
- item ,
1119
+ iteration . value ,
1138
1120
completedResults ,
1139
1121
exeContext ,
1140
1122
itemType ,
@@ -1227,24 +1209,7 @@ async function completeAsyncIteratorValueWithPossibleStream(
1227
1209
}
1228
1210
1229
1211
const item = iteration . value ;
1230
- // TODO: add tests for stream backed by asyncIterator that returns a promise
1231
- /* c8 ignore start */
1232
- if ( isPromise ( item ) ) {
1233
- completedResults . push (
1234
- completePromisedListItemValue (
1235
- item ,
1236
- exeContext ,
1237
- itemType ,
1238
- fieldGroup ,
1239
- info ,
1240
- itemPath ,
1241
- incrementalContext ,
1242
- deferMap ,
1243
- ) ,
1244
- ) ;
1245
- containsPromise = true ;
1246
- } else if (
1247
- /* c8 ignore stop */
1212
+ if (
1248
1213
completeListItemValue (
1249
1214
item ,
1250
1215
completedResults ,
@@ -1368,21 +1333,7 @@ function completeIterableValue(
1368
1333
// since from here on it is not ever accessed by resolver functions.
1369
1334
const itemPath = addPath ( path , index , undefined ) ;
1370
1335
1371
- if ( isPromise ( item ) ) {
1372
- completedResults . push (
1373
- completePromisedListItemValue (
1374
- item ,
1375
- exeContext ,
1376
- itemType ,
1377
- fieldGroup ,
1378
- info ,
1379
- itemPath ,
1380
- incrementalContext ,
1381
- deferMap ,
1382
- ) ,
1383
- ) ;
1384
- containsPromise = true ;
1385
- } else if (
1336
+ if (
1386
1337
completeListItemValue (
1387
1338
item ,
1388
1339
completedResults ,
@@ -1459,21 +1410,7 @@ function completeIterableValueWithPossibleStream(
1459
1410
// since from here on it is not ever accessed by resolver functions.
1460
1411
const itemPath = addPath ( path , index , undefined ) ;
1461
1412
1462
- if ( isPromise ( item ) ) {
1463
- completedResults . push (
1464
- completePromisedListItemValue (
1465
- item ,
1466
- exeContext ,
1467
- itemType ,
1468
- fieldGroup ,
1469
- info ,
1470
- itemPath ,
1471
- incrementalContext ,
1472
- deferMap ,
1473
- ) ,
1474
- ) ;
1475
- containsPromise = true ;
1476
- } else if (
1413
+ if (
1477
1414
completeListItemValue (
1478
1415
item ,
1479
1416
completedResults ,
@@ -1513,6 +1450,22 @@ function completeListItemValue(
1513
1450
incrementalContext : IncrementalContext | undefined ,
1514
1451
deferMap : ReadonlyMap < DeferUsage , DeferredFragmentRecord > | undefined ,
1515
1452
) : boolean {
1453
+ if ( isPromise ( item ) ) {
1454
+ completedResults . push (
1455
+ completePromisedValue (
1456
+ exeContext ,
1457
+ itemType ,
1458
+ fieldGroup ,
1459
+ info ,
1460
+ itemPath ,
1461
+ item ,
1462
+ incrementalContext ,
1463
+ deferMap ,
1464
+ ) ,
1465
+ ) ;
1466
+ return true ;
1467
+ }
1468
+
1516
1469
try {
1517
1470
const completedItem = completeValue (
1518
1471
exeContext ,
@@ -1559,45 +1512,6 @@ function completeListItemValue(
1559
1512
return false ;
1560
1513
}
1561
1514
1562
- async function completePromisedListItemValue (
1563
- item : unknown ,
1564
- exeContext : ExecutionContext ,
1565
- itemType : GraphQLOutputType ,
1566
- fieldGroup : FieldGroup ,
1567
- info : GraphQLResolveInfo ,
1568
- itemPath : Path ,
1569
- incrementalContext : IncrementalContext | undefined ,
1570
- deferMap : ReadonlyMap < DeferUsage , DeferredFragmentRecord > | undefined ,
1571
- ) : Promise < unknown > {
1572
- try {
1573
- const resolved = await item ;
1574
- let completed = completeValue (
1575
- exeContext ,
1576
- itemType ,
1577
- fieldGroup ,
1578
- info ,
1579
- itemPath ,
1580
- resolved ,
1581
- incrementalContext ,
1582
- deferMap ,
1583
- ) ;
1584
- if ( isPromise ( completed ) ) {
1585
- completed = await completed ;
1586
- }
1587
- return completed ;
1588
- } catch ( rawError ) {
1589
- handleFieldError (
1590
- rawError ,
1591
- exeContext ,
1592
- itemType ,
1593
- fieldGroup ,
1594
- itemPath ,
1595
- incrementalContext ,
1596
- ) ;
1597
- return null ;
1598
- }
1599
- }
1600
-
1601
1515
/**
1602
1516
* Complete a Scalar or Enum by serializing to a valid value, returning
1603
1517
* null if serialization is not possible.
0 commit comments