@@ -1134,27 +1134,9 @@ async function completeAsyncIteratorValue(
1134
1134
break ;
1135
1135
}
1136
1136
1137
- const item = iteration . value ;
1138
- // TODO: add tests for stream backed by asyncIterator that returns a promise
1139
- /* c8 ignore start */
1140
- if ( isPromise ( item ) ) {
1141
- completedResults . push (
1142
- completePromisedListItemValue (
1143
- item ,
1144
- exeContext ,
1145
- itemType ,
1146
- fieldGroup ,
1147
- info ,
1148
- itemPath ,
1149
- incrementalContext ,
1150
- deferMap ,
1151
- ) ,
1152
- ) ;
1153
- containsPromise = true ;
1154
- } else if (
1155
- /* c8 ignore stop */
1137
+ if (
1156
1138
completeListItemValue (
1157
- item ,
1139
+ iteration . value ,
1158
1140
completedResults ,
1159
1141
exeContext ,
1160
1142
itemType ,
@@ -1248,24 +1230,7 @@ async function completeAsyncIteratorValueWithPossibleStream(
1248
1230
}
1249
1231
1250
1232
const item = iteration . value ;
1251
- // TODO: add tests for stream backed by asyncIterator that returns a promise
1252
- /* c8 ignore start */
1253
- if ( isPromise ( item ) ) {
1254
- completedResults . push (
1255
- completePromisedListItemValue (
1256
- item ,
1257
- exeContext ,
1258
- itemType ,
1259
- fieldGroup ,
1260
- info ,
1261
- itemPath ,
1262
- incrementalContext ,
1263
- deferMap ,
1264
- ) ,
1265
- ) ;
1266
- containsPromise = true ;
1267
- } else if (
1268
- /* c8 ignore stop */
1233
+ if (
1269
1234
completeListItemValue (
1270
1235
item ,
1271
1236
completedResults ,
@@ -1389,21 +1354,7 @@ function completeIterableValue(
1389
1354
// since from here on it is not ever accessed by resolver functions.
1390
1355
const itemPath = addPath ( path , index , undefined ) ;
1391
1356
1392
- if ( isPromise ( item ) ) {
1393
- completedResults . push (
1394
- completePromisedListItemValue (
1395
- item ,
1396
- exeContext ,
1397
- itemType ,
1398
- fieldGroup ,
1399
- info ,
1400
- itemPath ,
1401
- incrementalContext ,
1402
- deferMap ,
1403
- ) ,
1404
- ) ;
1405
- containsPromise = true ;
1406
- } else if (
1357
+ if (
1407
1358
completeListItemValue (
1408
1359
item ,
1409
1360
completedResults ,
@@ -1472,21 +1423,7 @@ function completeIterableValueWithPossibleStream(
1472
1423
// since from here on it is not ever accessed by resolver functions.
1473
1424
const itemPath = addPath ( path , index , undefined ) ;
1474
1425
1475
- if ( isPromise ( item ) ) {
1476
- completedResults . push (
1477
- completePromisedListItemValue (
1478
- item ,
1479
- exeContext ,
1480
- itemType ,
1481
- fieldGroup ,
1482
- info ,
1483
- itemPath ,
1484
- incrementalContext ,
1485
- deferMap ,
1486
- ) ,
1487
- ) ;
1488
- containsPromise = true ;
1489
- } else if (
1426
+ if (
1490
1427
completeListItemValue (
1491
1428
item ,
1492
1429
completedResults ,
@@ -1525,6 +1462,22 @@ function completeListItemValue(
1525
1462
incrementalContext : IncrementalContext | undefined ,
1526
1463
deferMap : ReadonlyMap < DeferUsage , DeferredFragmentRecord > | undefined ,
1527
1464
) : boolean {
1465
+ if ( isPromise ( item ) ) {
1466
+ completedResults . push (
1467
+ completePromisedValue (
1468
+ exeContext ,
1469
+ itemType ,
1470
+ fieldGroup ,
1471
+ info ,
1472
+ itemPath ,
1473
+ item ,
1474
+ incrementalContext ,
1475
+ deferMap ,
1476
+ ) ,
1477
+ ) ;
1478
+ return true ;
1479
+ }
1480
+
1528
1481
try {
1529
1482
const completedItem = completeValue (
1530
1483
exeContext ,
@@ -1571,45 +1524,6 @@ function completeListItemValue(
1571
1524
return false ;
1572
1525
}
1573
1526
1574
- async function completePromisedListItemValue (
1575
- item : unknown ,
1576
- exeContext : ExecutionContext ,
1577
- itemType : GraphQLOutputType ,
1578
- fieldGroup : FieldGroup ,
1579
- info : GraphQLResolveInfo ,
1580
- itemPath : Path ,
1581
- incrementalContext : IncrementalContext | undefined ,
1582
- deferMap : ReadonlyMap < DeferUsage , DeferredFragmentRecord > | undefined ,
1583
- ) : Promise < unknown > {
1584
- try {
1585
- const resolved = await item ;
1586
- let completed = completeValue (
1587
- exeContext ,
1588
- itemType ,
1589
- fieldGroup ,
1590
- info ,
1591
- itemPath ,
1592
- resolved ,
1593
- incrementalContext ,
1594
- deferMap ,
1595
- ) ;
1596
- if ( isPromise ( completed ) ) {
1597
- completed = await completed ;
1598
- }
1599
- return completed ;
1600
- } catch ( rawError ) {
1601
- handleFieldError (
1602
- rawError ,
1603
- exeContext ,
1604
- itemType ,
1605
- fieldGroup ,
1606
- itemPath ,
1607
- incrementalContext ,
1608
- ) ;
1609
- return null ;
1610
- }
1611
- }
1612
-
1613
1527
/**
1614
1528
* Complete a Scalar or Enum by serializing to a valid value, returning
1615
1529
* null if serialization is not possible.
0 commit comments