Skip to content

Commit e15c3ec

Browse files
authored
Add test for consolidating grouped field sets properly into deferred 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.
1 parent 92f9bb0 commit e15c3ec

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

src/execution/__tests__/defer-test.ts

+55
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,61 @@ describe('Execute: defer directive', () => {
11381138
]);
11391139
});
11401140

1141+
it('Correctly bundles varying subfields into incremental data records unique by defer combination, ignoring fields in a fragment masked by a parent defer', async () => {
1142+
const document = parse(`
1143+
query HeroNameQuery {
1144+
... @defer {
1145+
hero {
1146+
id
1147+
}
1148+
}
1149+
... @defer {
1150+
hero {
1151+
name
1152+
shouldBeWithNameDespiteAdditionalDefer: name
1153+
... @defer {
1154+
shouldBeWithNameDespiteAdditionalDefer: name
1155+
}
1156+
}
1157+
}
1158+
}
1159+
`);
1160+
const result = await complete(document);
1161+
expectJSON(result).toDeepEqual([
1162+
{
1163+
data: {},
1164+
pending: [
1165+
{ id: '0', path: [] },
1166+
{ id: '1', path: [] },
1167+
],
1168+
hasNext: true,
1169+
},
1170+
{
1171+
incremental: [
1172+
{
1173+
data: { hero: {} },
1174+
id: '0',
1175+
},
1176+
{
1177+
data: { id: '1' },
1178+
id: '0',
1179+
subPath: ['hero'],
1180+
},
1181+
{
1182+
data: {
1183+
name: 'Luke',
1184+
shouldBeWithNameDespiteAdditionalDefer: 'Luke',
1185+
},
1186+
id: '1',
1187+
subPath: ['hero'],
1188+
},
1189+
],
1190+
completed: [{ id: '0' }, { id: '1' }],
1191+
hasNext: false,
1192+
},
1193+
]);
1194+
});
1195+
11411196
it('Nulls cross defer boundaries, null first', async () => {
11421197
const document = parse(`
11431198
query {

0 commit comments

Comments
 (0)