Skip to content

Commit dd3d9e9

Browse files
committed
removing some deduplication
leaf fields cannot be deterministically deduplicated because it is unclear which payload will complete first
1 parent 3f52a2f commit dd3d9e9

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

src/execution/__tests__/defer-test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ describe('Execute: defer directive', () => {
591591
]);
592592
});
593593

594-
it('Can deduplicate fields with deferred fragments at multiple levels', async () => {
594+
it('Can deduplicate initial fields with deferred fragments at multiple levels', async () => {
595595
const document = parse(`
596596
query {
597597
hero {
@@ -642,13 +642,16 @@ describe('Execute: defer directive', () => {
642642
incremental: [
643643
{
644644
data: {
645+
bar: 'bar',
646+
baz: 'baz',
645647
bak: 'bak',
646648
},
647649
path: ['hero', 'nestedObject', 'deeperObject'],
648650
},
649651
{
650652
data: {
651653
deeperObject: {
654+
bar: 'bar',
652655
baz: 'baz',
653656
},
654657
},
@@ -729,7 +732,7 @@ describe('Execute: defer directive', () => {
729732
]);
730733
});
731734

732-
it('can deduplicate fields with deferred fragments in different branches at multiple non-overlapping levels', async () => {
735+
it('can deduplicate initial fields with deferred fragments in different branches at multiple non-overlapping levels', async () => {
733736
const document = parse(`
734737
query {
735738
a {
@@ -776,7 +779,9 @@ describe('Execute: defer directive', () => {
776779
incremental: [
777780
{
778781
data: {
779-
e: {},
782+
e: {
783+
f: 'f',
784+
},
780785
},
781786
path: ['a', 'b'],
782787
},

src/execution/execute.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -669,25 +669,15 @@ function shouldExecuteFieldSet(
669669
fieldSet: ReadonlyArray<TaggedFieldNode>,
670670
deferDepth: number | undefined,
671671
): boolean {
672-
if (deferDepth === undefined) {
672+
if (deferDepth === undefined || !isLeafType(getNamedType(returnType))) {
673673
return fieldSet.some(
674-
({ deferDepth: fieldDeferDepth }) => fieldDeferDepth === undefined,
674+
({ deferDepth: fieldDeferDepth }) => fieldDeferDepth === deferDepth,
675675
);
676676
}
677677

678-
if (!isLeafType(getNamedType(returnType))) {
679-
let hasDepth = false;
680-
for (const { deferDepth: fieldDeferDepth } of fieldSet) {
681-
if (fieldDeferDepth === deferDepth) {
682-
hasDepth = true;
683-
}
684-
}
685-
return hasDepth;
686-
}
687-
688678
let hasDepth = false;
689679
for (const { deferDepth: fieldDeferDepth } of fieldSet) {
690-
if (fieldDeferDepth === undefined || fieldDeferDepth < deferDepth) {
680+
if (fieldDeferDepth === undefined) {
691681
return false;
692682
}
693683
if (fieldDeferDepth === deferDepth) {

0 commit comments

Comments
 (0)