Skip to content

Expands over-eager merging of field fix to handle @defer consistently #2720

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

Merged
merged 1 commit into from
Aug 15, 2023

Conversation

pcmanus
Copy link
Contributor

@pcmanus pcmanus commented Aug 7, 2023

The previously committed #2713 fixed an issue introduced by #2387, ensuring that querying the same field with different directives applications was not merged, similar to what was/is done for fragments. But the exact behaviour slightly differs between fields and fragments when it comes to @defer in that for fragments, we never merge 2 similar fragments where both have @defer, which we do merge for fields. Or to put it more concretely, in the following query:

query Test($skipField: Boolean!) {
  x {
    ... on X @defer {
      a
    }
    ... on X @defer {
      b
    }
  }
}

the 2 ... on X @defer are not merged, resulting in 2 deferred sections that can run in parallel. But following #2713, query:

query Test($skipField: Boolean!) {
  x @defer {
    a
  }
  x @defer {
    b
  }
}

will merge both x @defer, resulting in a single deferred section.

This fix changes that later behaviour so that the 2 x @defer are not merged and result in 2 deferred sections, consistently with both 1) the case of fragments and 2) the behaviour prior to #2387.

@pcmanus pcmanus requested a review from a team as a code owner August 7, 2023 10:03
@netlify
Copy link

netlify bot commented Aug 7, 2023

👷 Deploy request for apollo-federation-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 534f5c2

@changeset-bot
Copy link

changeset-bot bot commented Aug 7, 2023

🦋 Changeset detected

Latest commit: 534f5c2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@apollo/federation-internals Patch
@apollo/gateway Patch
@apollo/composition Patch
@apollo/query-planner Patch
@apollo/query-graphs Patch
@apollo/subgraph Patch
apollo-federation-integration-testsuite Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 7, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@pcmanus pcmanus self-assigned this Aug 10, 2023
The previously committed [apollographql#2713](apollographql#2713) fixed an issue introduced by
[apollographql#2387](apollographql#2387), ensuring that querying the same field with different
directives applications was not merged, similar to what was/is done for fragments. But the exact behaviour slightly
differs between fields and fragments when it comes to `@defer` in that for fragments, we never merge 2 similar fragments
where both have `@defer`, which we do merge for fields. Or to put it more concretely, in the following query:
```graphq
query Test($skipField: Boolean!) {
  x {
    ... on X @defer {
      a
    }
    ... on X @defer {
      b
    }
  }
}
```
the 2 `... on X @defer` are not merged, resulting in 2 deferred sections that can run in parallel. But following
[apollographql#2713](apollographql#2713), query:
```graphq
query Test($skipField: Boolean!) {
  x @defer {
    a
  }
  x @defer {
    b
  }
}
```
_will_ merge both `x @defer`, resulting in a single deferred section.

This fix changes that later behaviour so that the 2 `x @defer` are not merged and result in 2 deferred sections,
consistently with both 1) the case of fragments and 2) the behaviour prior to
[apollographql#2387](apollographql#2387).
@jeffjakub jeffjakub merged commit 1add932 into apollographql:main Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants