Skip to content

Commit

Permalink
Add test for consolidating grouped field sets properly into deferred …
Browse files Browse the repository at this point in the history
…fragments (#3997)

Group field sets should be properly consolidated when some of the fields
in a sibling defer overlap with a child deferred fragment.

The child deferred fragment should not prompt creation of an additional incremental data record for that field, because the field would always be sent with the parent.
  • Loading branch information
yaacovCR committed May 9, 2024
1 parent 92f9bb0 commit e15c3ec
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/execution/__tests__/defer-test.ts
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 e15c3ec

Please sign in to comment.