Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for consolidating grouped field sets properly into deferred fragments #3997

Merged
merged 1 commit into from
May 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading