Skip to content

Commit

Permalink
incremental: add test
Browse files Browse the repository at this point in the history
add test for correctly bundling varying subfields into incremental data records unique by defer combination, ignoring fields in a fragment masked by a parent defer
  • Loading branch information
yaacovCR committed May 9, 2024
1 parent 92f9bb0 commit 98b9868
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/execution/__tests__/defer-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,61 @@ describe('Execute: defer directive', () => {
]);
});

it('Correctly bundles varying subfields into incremental data records unique by defer combination, ignoring fields in a fragment masked by a parent defer', async () => {
const document = parse(`
query HeroNameQuery {
... @defer {
hero {
id
}
}
... @defer {
hero {
name
shouldBeWithNameDespiteAdditionalDefer: name
... @defer {
shouldBeWithNameDespiteAdditionalDefer: name
}
}
}
}
`);
const result = await complete(document);
expectJSON(result).toDeepEqual([
{
data: {},
pending: [
{ id: '0', path: [] },
{ id: '1', path: [] },
],
hasNext: true,
},
{
incremental: [
{
data: { hero: {} },
id: '0',
},
{
data: { id: '1' },
id: '0',
subPath: ['hero'],
},
{
data: {
name: 'Luke',
shouldBeWithNameDespiteAdditionalDefer: 'Luke',
},
id: '1',
subPath: ['hero'],
},
],
completed: [{ id: '0' }, { id: '1' }],
hasNext: false,
},
]);
});

it('Nulls cross defer boundaries, null first', async () => {
const document = parse(`
query {
Expand Down

0 comments on commit 98b9868

Please sign in to comment.