@@ -476,6 +476,40 @@ describe('Execute: defer directive', () => {
476
476
} ) ;
477
477
} ) ;
478
478
479
+ it ( 'Emits children of empty defer fragments' , async ( ) => {
480
+ const document = parse ( `
481
+ query HeroNameQuery {
482
+ hero {
483
+ ... @defer {
484
+ ... @defer {
485
+ name
486
+ }
487
+ }
488
+ }
489
+ }
490
+ ` ) ;
491
+ const result = await complete ( document ) ;
492
+ expectJSON ( result ) . toDeepEqual ( [
493
+ {
494
+ data : {
495
+ hero : { } ,
496
+ } ,
497
+ pending : [ { id : '0' , path : [ 'hero' ] } ] ,
498
+ hasNext : true ,
499
+ } ,
500
+ {
501
+ pending : [ { id : '1' , path : [ 'hero' ] } ] ,
502
+ completed : [ { id : '0' } ] ,
503
+ hasNext : true ,
504
+ } ,
505
+ {
506
+ incremental : [ { data : { name : 'Luke' } , id : '1' } ] ,
507
+ completed : [ { id : '1' } ] ,
508
+ hasNext : false ,
509
+ } ,
510
+ ] ) ;
511
+ } ) ;
512
+
479
513
it ( 'Can separately emit defer fragments with different labels with varying fields' , async ( ) => {
480
514
const document = parse ( `
481
515
query HeroNameQuery {
@@ -760,13 +794,38 @@ describe('Execute: defer directive', () => {
760
794
] ,
761
795
hasNext : true ,
762
796
} ,
797
+ // TODO: these pending notifications and the subsequent payloads are all empty
798
+ // fixed by https://github.com/graphql/graphql-js/pull/3993
763
799
{
800
+ pending : [
801
+ { id : '3' , path : [ 'hero' , 'friends' , 0 ] } ,
802
+ { id : '4' , path : [ 'hero' , 'friends' , 1 ] } ,
803
+ { id : '5' , path : [ 'hero' , 'friends' , 2 ] } ,
804
+ ] ,
764
805
incremental : [
765
806
{ data : { id : '2' , name : 'Han' } , id : '0' } ,
766
807
{ data : { id : '3' , name : 'Leia' } , id : '1' } ,
767
808
{ data : { id : '4' , name : 'C-3PO' } , id : '2' } ,
768
809
] ,
769
810
completed : [ { id : '0' } , { id : '1' } , { id : '2' } ] ,
811
+ hasNext : true ,
812
+ } ,
813
+ {
814
+ pending : [
815
+ { id : '6' , path : [ 'hero' , 'friends' , 0 ] } ,
816
+ { id : '7' , path : [ 'hero' , 'friends' , 1 ] } ,
817
+ { id : '8' , path : [ 'hero' , 'friends' , 2 ] } ,
818
+ ] ,
819
+ completed : [ { id : '3' } , { id : '4' } , { id : '5' } ] ,
820
+ hasNext : true ,
821
+ } ,
822
+ {
823
+ pending : [
824
+ { id : '9' , path : [ 'hero' , 'friends' , 0 ] } ,
825
+ { id : '10' , path : [ 'hero' , 'friends' , 1 ] } ,
826
+ { id : '11' , path : [ 'hero' , 'friends' , 2 ] } ,
827
+ ] ,
828
+ completed : [ { id : '6' } , { id : '7' } , { id : '8' } ] ,
770
829
hasNext : false ,
771
830
} ,
772
831
] ) ;
0 commit comments