File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -450,6 +450,56 @@ describe('Execute: stream directive', () => {
450
450
} ,
451
451
] ) ;
452
452
} ) ;
453
+ it ( 'Can stream a field that returns a list of promises with nested promises' , async ( ) => {
454
+ const document = parse ( `
455
+ query {
456
+ friendList @stream(initialCount: 2) {
457
+ name
458
+ id
459
+ }
460
+ }
461
+ ` ) ;
462
+ const result = await complete ( document , {
463
+ friendList : ( ) =>
464
+ friends . map ( ( f ) =>
465
+ Promise . resolve ( {
466
+ name : Promise . resolve ( f . name ) ,
467
+ id : Promise . resolve ( f . id ) ,
468
+ } ) ,
469
+ ) ,
470
+ } ) ;
471
+ expectJSON ( result ) . toDeepEqual ( [
472
+ {
473
+ data : {
474
+ friendList : [
475
+ {
476
+ name : 'Luke' ,
477
+ id : '1' ,
478
+ } ,
479
+ {
480
+ name : 'Han' ,
481
+ id : '2' ,
482
+ } ,
483
+ ] ,
484
+ } ,
485
+ hasNext : true ,
486
+ } ,
487
+ {
488
+ incremental : [
489
+ {
490
+ items : [
491
+ {
492
+ name : 'Leia' ,
493
+ id : '3' ,
494
+ } ,
495
+ ] ,
496
+ path : [ 'friendList' , 2 ] ,
497
+ } ,
498
+ ] ,
499
+ hasNext : false ,
500
+ } ,
501
+ ] ) ;
502
+ } ) ;
453
503
it ( 'Handles rejections in a field that returns a list of promises before initialCount is reached' , async ( ) => {
454
504
const document = parse ( `
455
505
query {
You can’t perform that action at this time.
0 commit comments