@@ -1135,7 +1135,9 @@ describe('Execute: stream directive', () => {
1135
1135
hasNext : true ,
1136
1136
} ) ;
1137
1137
1138
- const result2 = await iterator . next ( ) ;
1138
+ const result2Promise = iterator . next ( ) ;
1139
+ resolveIterableCompletion ( ) ;
1140
+ const result2 = await result2Promise ;
1139
1141
expectJSON ( result2 ) . toDeepEqual ( {
1140
1142
value : {
1141
1143
incremental : [
@@ -1144,18 +1146,6 @@ describe('Execute: stream directive', () => {
1144
1146
path : [ 'friendList' , 0 ] ,
1145
1147
label : 'DeferName' ,
1146
1148
} ,
1147
- ] ,
1148
- hasNext : true ,
1149
- } ,
1150
- done : false ,
1151
- } ) ;
1152
-
1153
- const result3Promise = iterator . next ( ) ;
1154
- resolveIterableCompletion ( ) ;
1155
- const result3 = await result3Promise ;
1156
- expectJSON ( result3 ) . toDeepEqual ( {
1157
- value : {
1158
- incremental : [
1159
1149
{
1160
1150
items : [ { id : '2' } ] ,
1161
1151
path : [ 'friendList' , 1 ] ,
@@ -1166,10 +1156,11 @@ describe('Execute: stream directive', () => {
1166
1156
} ,
1167
1157
done : false ,
1168
1158
} ) ;
1169
- const result4Promise = iterator . next ( ) ;
1159
+
1160
+ const result3Promise = iterator . next ( ) ;
1170
1161
resolveSlowField ( 'Han' ) ;
1171
- const result4 = await result4Promise ;
1172
- expectJSON ( result4 ) . toDeepEqual ( {
1162
+ const result3 = await result3Promise ;
1163
+ expectJSON ( result3 ) . toDeepEqual ( {
1173
1164
value : {
1174
1165
incremental : [
1175
1166
{
@@ -1182,8 +1173,8 @@ describe('Execute: stream directive', () => {
1182
1173
} ,
1183
1174
done : false ,
1184
1175
} ) ;
1185
- const result5 = await iterator . next ( ) ;
1186
- expectJSON ( result5 ) . toDeepEqual ( {
1176
+ const result4 = await iterator . next ( ) ;
1177
+ expectJSON ( result4 ) . toDeepEqual ( {
1187
1178
value : undefined ,
1188
1179
done : true ,
1189
1180
} ) ;
@@ -1230,7 +1221,9 @@ describe('Execute: stream directive', () => {
1230
1221
hasNext : true ,
1231
1222
} ) ;
1232
1223
1233
- const result2 = await iterator . next ( ) ;
1224
+ const result2Promise = iterator . next ( ) ;
1225
+ resolveSlowField ( 'Han' ) ;
1226
+ const result2 = await result2Promise ;
1234
1227
expectJSON ( result2 ) . toDeepEqual ( {
1235
1228
value : {
1236
1229
incremental : [
@@ -1239,18 +1232,6 @@ describe('Execute: stream directive', () => {
1239
1232
path : [ 'friendList' , 0 ] ,
1240
1233
label : 'DeferName' ,
1241
1234
} ,
1242
- ] ,
1243
- hasNext : true ,
1244
- } ,
1245
- done : false ,
1246
- } ) ;
1247
-
1248
- const result3Promise = iterator . next ( ) ;
1249
- resolveSlowField ( 'Han' ) ;
1250
- const result3 = await result3Promise ;
1251
- expectJSON ( result3 ) . toDeepEqual ( {
1252
- value : {
1253
- incremental : [
1254
1235
{
1255
1236
items : [ { id : '2' } ] ,
1256
1237
path : [ 'friendList' , 1 ] ,
@@ -1261,8 +1242,9 @@ describe('Execute: stream directive', () => {
1261
1242
} ,
1262
1243
done : false ,
1263
1244
} ) ;
1264
- const result4 = await iterator . next ( ) ;
1265
- expectJSON ( result4 ) . toDeepEqual ( {
1245
+
1246
+ const result3 = await iterator . next ( ) ;
1247
+ expectJSON ( result3 ) . toDeepEqual ( {
1266
1248
value : {
1267
1249
incremental : [
1268
1250
{
@@ -1275,16 +1257,16 @@ describe('Execute: stream directive', () => {
1275
1257
} ,
1276
1258
done : false ,
1277
1259
} ) ;
1278
- const result5Promise = iterator . next ( ) ;
1260
+ const result4Promise = iterator . next ( ) ;
1279
1261
resolveIterableCompletion ( ) ;
1280
- const result5 = await result5Promise ;
1281
- expectJSON ( result5 ) . toDeepEqual ( {
1262
+ const result4 = await result4Promise ;
1263
+ expectJSON ( result4 ) . toDeepEqual ( {
1282
1264
value : { hasNext : false } ,
1283
1265
done : false ,
1284
1266
} ) ;
1285
1267
1286
- const result6 = await iterator . next ( ) ;
1287
- expectJSON ( result6 ) . toDeepEqual ( {
1268
+ const result5 = await iterator . next ( ) ;
1269
+ expectJSON ( result5 ) . toDeepEqual ( {
1288
1270
value : undefined ,
1289
1271
done : true ,
1290
1272
} ) ;
@@ -1341,22 +1323,8 @@ describe('Execute: stream directive', () => {
1341
1323
} ) ;
1342
1324
const returnPromise = iterator . return ( ) ;
1343
1325
1344
- // these results had started processing before return was called
1345
1326
const result2 = await iterator . next ( ) ;
1346
1327
expectJSON ( result2 ) . toDeepEqual ( {
1347
- done : false ,
1348
- value : {
1349
- incremental : [
1350
- {
1351
- data : { name : 'Luke' } ,
1352
- path : [ 'friendList' , 0 ] ,
1353
- } ,
1354
- ] ,
1355
- hasNext : true ,
1356
- } ,
1357
- } ) ;
1358
- const result3 = await iterator . next ( ) ;
1359
- expectJSON ( result3 ) . toDeepEqual ( {
1360
1328
done : true ,
1361
1329
value : undefined ,
1362
1330
} ) ;
@@ -1411,24 +1379,8 @@ describe('Execute: stream directive', () => {
1411
1379
1412
1380
const returnPromise = iterator . return ( ) ;
1413
1381
1414
- // this result had started processing before return was called
1415
1382
const result2 = await iterator . next ( ) ;
1416
1383
expectJSON ( result2 ) . toDeepEqual ( {
1417
- done : false ,
1418
- value : {
1419
- incremental : [
1420
- {
1421
- items : [ { id : '2' , name : 'Han' } ] ,
1422
- path : [ 'friendList' , 1 ] ,
1423
- } ,
1424
- ] ,
1425
- hasNext : true ,
1426
- } ,
1427
- } ) ;
1428
-
1429
- // third result is not returned because async iterator has returned
1430
- const result3 = await iterator . next ( ) ;
1431
- expectJSON ( result3 ) . toDeepEqual ( {
1432
1384
done : true ,
1433
1385
value : undefined ,
1434
1386
} ) ;
@@ -1486,24 +1438,8 @@ describe('Execute: stream directive', () => {
1486
1438
1487
1439
const throwPromise = iterator . throw ( new Error ( 'bad' ) ) ;
1488
1440
1489
- // these results had started processing before return was called
1490
1441
const result2 = await iterator . next ( ) ;
1491
1442
expectJSON ( result2 ) . toDeepEqual ( {
1492
- done : false ,
1493
- value : {
1494
- incremental : [
1495
- {
1496
- data : { name : 'Luke' } ,
1497
- path : [ 'friendList' , 0 ] ,
1498
- } ,
1499
- ] ,
1500
- hasNext : true ,
1501
- } ,
1502
- } ) ;
1503
-
1504
- // this result is not returned because async iterator has returned
1505
- const result3 = await iterator . next ( ) ;
1506
- expectJSON ( result3 ) . toDeepEqual ( {
1507
1443
done : true ,
1508
1444
value : undefined ,
1509
1445
} ) ;
0 commit comments