@@ -394,21 +394,13 @@ describe('Execute: defer directive', () => {
394
394
}
395
395
` ) ;
396
396
const result = await complete ( document ) ;
397
- expectJSON ( result ) . toDeepEqual ( [
398
- {
399
- data : {
400
- hero : {
401
- name : 'Luke' ,
402
- } ,
397
+ expectJSON ( result ) . toDeepEqual ( {
398
+ data : {
399
+ hero : {
400
+ name : 'Luke' ,
403
401
} ,
404
- pending : [ { id : '0' , path : [ 'hero' ] , label : 'DeferTop' } ] ,
405
- hasNext : true ,
406
- } ,
407
- {
408
- completed : [ { id : '0' } ] ,
409
- hasNext : false ,
410
402
} ,
411
- ] ) ;
403
+ } ) ;
412
404
} ) ;
413
405
it ( 'Can defer a fragment that is also not deferred, non-deferred fragment is first' , async ( ) => {
414
406
const document = parse ( `
@@ -423,21 +415,13 @@ describe('Execute: defer directive', () => {
423
415
}
424
416
` ) ;
425
417
const result = await complete ( document ) ;
426
- expectJSON ( result ) . toDeepEqual ( [
427
- {
428
- data : {
429
- hero : {
430
- name : 'Luke' ,
431
- } ,
418
+ expectJSON ( result ) . toDeepEqual ( {
419
+ data : {
420
+ hero : {
421
+ name : 'Luke' ,
432
422
} ,
433
- pending : [ { id : '0' , path : [ 'hero' ] , label : 'DeferTop' } ] ,
434
- hasNext : true ,
435
- } ,
436
- {
437
- completed : [ { id : '0' } ] ,
438
- hasNext : false ,
439
423
} ,
440
- ] ) ;
424
+ } ) ;
441
425
} ) ;
442
426
443
427
it ( 'Can defer an inline fragment' , async ( ) => {
@@ -481,19 +465,11 @@ describe('Execute: defer directive', () => {
481
465
}
482
466
` ) ;
483
467
const result = await complete ( document ) ;
484
- expectJSON ( result ) . toDeepEqual ( [
485
- {
486
- data : {
487
- hero : { } ,
488
- } ,
489
- pending : [ { id : '0' , path : [ 'hero' ] } ] ,
490
- hasNext : true ,
491
- } ,
492
- {
493
- completed : [ { id : '0' } ] ,
494
- hasNext : false ,
468
+ expectJSON ( result ) . toDeepEqual ( {
469
+ data : {
470
+ hero : { } ,
495
471
} ,
496
- ] ) ;
472
+ } ) ;
497
473
} ) ;
498
474
499
475
it ( 'Can separately emit defer fragments with different labels with varying fields' , async ( ) => {
@@ -775,40 +751,18 @@ describe('Execute: defer directive', () => {
775
751
data : { hero : { friends : [ { } , { } , { } ] } } ,
776
752
pending : [
777
753
{ id : '0' , path : [ 'hero' , 'friends' , 0 ] } ,
778
- { id : '1' , path : [ 'hero' , 'friends' , 0 ] } ,
779
- { id : '2' , path : [ 'hero' , 'friends' , 0 ] } ,
780
- { id : '3' , path : [ 'hero' , 'friends' , 0 ] } ,
781
- { id : '4' , path : [ 'hero' , 'friends' , 1 ] } ,
782
- { id : '5' , path : [ 'hero' , 'friends' , 1 ] } ,
783
- { id : '6' , path : [ 'hero' , 'friends' , 1 ] } ,
784
- { id : '7' , path : [ 'hero' , 'friends' , 1 ] } ,
785
- { id : '8' , path : [ 'hero' , 'friends' , 2 ] } ,
786
- { id : '9' , path : [ 'hero' , 'friends' , 2 ] } ,
787
- { id : '10' , path : [ 'hero' , 'friends' , 2 ] } ,
788
- { id : '11' , path : [ 'hero' , 'friends' , 2 ] } ,
754
+ { id : '1' , path : [ 'hero' , 'friends' , 1 ] } ,
755
+ { id : '2' , path : [ 'hero' , 'friends' , 2 ] } ,
789
756
] ,
790
757
hasNext : true ,
791
758
} ,
792
759
{
793
760
incremental : [
794
761
{ data : { id : '2' , name : 'Han' } , id : '0' } ,
795
- { data : { id : '3' , name : 'Leia' } , id : '4' } ,
796
- { data : { id : '4' , name : 'C-3PO' } , id : '8' } ,
797
- ] ,
798
- completed : [
799
- { id : '1' } ,
800
- { id : '2' } ,
801
- { id : '3' } ,
802
- { id : '5' } ,
803
- { id : '6' } ,
804
- { id : '7' } ,
805
- { id : '9' } ,
806
- { id : '10' } ,
807
- { id : '11' } ,
808
- { id : '0' } ,
809
- { id : '4' } ,
810
- { id : '8' } ,
762
+ { data : { id : '3' , name : 'Leia' } , id : '1' } ,
763
+ { data : { id : '4' , name : 'C-3PO' } , id : '2' } ,
811
764
] ,
765
+ completed : [ { id : '0' } , { id : '1' } , { id : '2' } ] ,
812
766
hasNext : false ,
813
767
} ,
814
768
] ) ;
@@ -1494,21 +1448,13 @@ describe('Execute: defer directive', () => {
1494
1448
}
1495
1449
` ) ;
1496
1450
const result = await complete ( document ) ;
1497
- expectJSON ( result ) . toDeepEqual ( [
1498
- {
1499
- data : {
1500
- hero : {
1501
- friends : [ { name : 'Han' } , { name : 'Leia' } , { name : 'C-3PO' } ] ,
1502
- } ,
1451
+ expectJSON ( result ) . toDeepEqual ( {
1452
+ data : {
1453
+ hero : {
1454
+ friends : [ { name : 'Han' } , { name : 'Leia' } , { name : 'C-3PO' } ] ,
1503
1455
} ,
1504
- pending : [ { id : '0' , path : [ 'hero' ] } ] ,
1505
- hasNext : true ,
1506
1456
} ,
1507
- {
1508
- completed : [ { id : '0' } ] ,
1509
- hasNext : false ,
1510
- } ,
1511
- ] ) ;
1457
+ } ) ;
1512
1458
} ) ;
1513
1459
1514
1460
it ( 'Deduplicates async iterable list fields' , async ( ) => {
@@ -1534,17 +1480,9 @@ describe('Execute: defer directive', () => {
1534
1480
} ,
1535
1481
} ,
1536
1482
} ) ;
1537
- expectJSON ( result ) . toDeepEqual ( [
1538
- {
1539
- data : { hero : { friends : [ { name : 'Han' } ] } } ,
1540
- pending : [ { id : '0' , path : [ 'hero' ] } ] ,
1541
- hasNext : true ,
1542
- } ,
1543
- {
1544
- completed : [ { id : '0' } ] ,
1545
- hasNext : false ,
1546
- } ,
1547
- ] ) ;
1483
+ expectJSON ( result ) . toDeepEqual ( {
1484
+ data : { hero : { friends : [ { name : 'Han' } ] } } ,
1485
+ } ) ;
1548
1486
} ) ;
1549
1487
1550
1488
it ( 'Deduplicates empty async iterable list fields' , async ( ) => {
@@ -1571,17 +1509,9 @@ describe('Execute: defer directive', () => {
1571
1509
} ,
1572
1510
} ,
1573
1511
} ) ;
1574
- expectJSON ( result ) . toDeepEqual ( [
1575
- {
1576
- data : { hero : { friends : [ ] } } ,
1577
- pending : [ { id : '0' , path : [ 'hero' ] } ] ,
1578
- hasNext : true ,
1579
- } ,
1580
- {
1581
- completed : [ { id : '0' } ] ,
1582
- hasNext : false ,
1583
- } ,
1584
- ] ) ;
1512
+ expectJSON ( result ) . toDeepEqual ( {
1513
+ data : { hero : { friends : [ ] } } ,
1514
+ } ) ;
1585
1515
} ) ;
1586
1516
1587
1517
it ( 'Does not deduplicate list fields with non-overlapping fields' , async ( ) => {
@@ -1655,17 +1585,9 @@ describe('Execute: defer directive', () => {
1655
1585
friends : ( ) => [ ] ,
1656
1586
} ,
1657
1587
} ) ;
1658
- expectJSON ( result ) . toDeepEqual ( [
1659
- {
1660
- data : { hero : { friends : [ ] } } ,
1661
- pending : [ { id : '0' , path : [ 'hero' ] } ] ,
1662
- hasNext : true ,
1663
- } ,
1664
- {
1665
- completed : [ { id : '0' } ] ,
1666
- hasNext : false ,
1667
- } ,
1668
- ] ) ;
1588
+ expectJSON ( result ) . toDeepEqual ( {
1589
+ data : { hero : { friends : [ ] } } ,
1590
+ } ) ;
1669
1591
} ) ;
1670
1592
1671
1593
it ( 'Deduplicates null object fields' , async ( ) => {
@@ -1689,17 +1611,9 @@ describe('Execute: defer directive', () => {
1689
1611
nestedObject : ( ) => null ,
1690
1612
} ,
1691
1613
} ) ;
1692
- expectJSON ( result ) . toDeepEqual ( [
1693
- {
1694
- data : { hero : { nestedObject : null } } ,
1695
- pending : [ { id : '0' , path : [ 'hero' ] } ] ,
1696
- hasNext : true ,
1697
- } ,
1698
- {
1699
- completed : [ { id : '0' } ] ,
1700
- hasNext : false ,
1701
- } ,
1702
- ] ) ;
1614
+ expectJSON ( result ) . toDeepEqual ( {
1615
+ data : { hero : { nestedObject : null } } ,
1616
+ } ) ;
1703
1617
} ) ;
1704
1618
1705
1619
it ( 'Deduplicates promise object fields' , async ( ) => {
@@ -1722,17 +1636,9 @@ describe('Execute: defer directive', () => {
1722
1636
nestedObject : ( ) => Promise . resolve ( { name : 'foo' } ) ,
1723
1637
} ,
1724
1638
} ) ;
1725
- expectJSON ( result ) . toDeepEqual ( [
1726
- {
1727
- data : { hero : { nestedObject : { name : 'foo' } } } ,
1728
- pending : [ { id : '0' , path : [ 'hero' ] } ] ,
1729
- hasNext : true ,
1730
- } ,
1731
- {
1732
- completed : [ { id : '0' } ] ,
1733
- hasNext : false ,
1734
- } ,
1735
- ] ) ;
1639
+ expectJSON ( result ) . toDeepEqual ( {
1640
+ data : { hero : { nestedObject : { name : 'foo' } } } ,
1641
+ } ) ;
1736
1642
} ) ;
1737
1643
1738
1644
it ( 'Handles errors thrown in deferred fragments' , async ( ) => {
0 commit comments