Skip to content

Commit 3ffb33c

Browse files
committed
add test to complete coverage
1 parent e758f46 commit 3ffb33c

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

src/execution/__tests__/stream-test.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,56 @@ describe('Execute: stream directive', () => {
450450
},
451451
]);
452452
});
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+
});
453503
it('Handles rejections in a field that returns a list of promises before initialCount is reached', async () => {
454504
const document = parse(`
455505
query {

0 commit comments

Comments
 (0)