Skip to content

Commit

Permalink
add test to complete coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
yaacovCR committed Dec 27, 2022
1 parent e758f46 commit 3ffb33c
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/execution/__tests__/stream-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,56 @@ describe('Execute: stream directive', () => {
},
]);
});
it('Can stream a field that returns a list of promises with nested promises', async () => {
const document = parse(`
query {
friendList @stream(initialCount: 2) {
name
id
}
}
`);
const result = await complete(document, {
friendList: () =>
friends.map((f) =>
Promise.resolve({
name: Promise.resolve(f.name),
id: Promise.resolve(f.id),
}),
),
});
expectJSON(result).toDeepEqual([
{
data: {
friendList: [
{
name: 'Luke',
id: '1',
},
{
name: 'Han',
id: '2',
},
],
},
hasNext: true,
},
{
incremental: [
{
items: [
{
name: 'Leia',
id: '3',
},
],
path: ['friendList', 2],
},
],
hasNext: false,
},
]);
});
it('Handles rejections in a field that returns a list of promises before initialCount is reached', async () => {
const document = parse(`
query {
Expand Down

0 comments on commit 3ffb33c

Please sign in to comment.