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

Fix fragment expansion nuking @defer and other minor @defer updates #2093

Merged
merged 5 commits into from
Aug 29, 2022

Conversation

pcmanus
Copy link
Contributor

@pcmanus pcmanus commented Aug 25, 2022

The patch from #1911 has a small bug in that it tries to avoid adding useless type conditions (inline fragments) when it expands named fragments, but it forgets to check if there is directives first and so "nuke" any such directives if there is one. Effectively, this means that if there is a @defer applied to a fragment spread, it gets lost and ignore.

Unfortunately, the @defer unit tests were all using inline fragments, so added a test to fix that coverage and the one-liner fix for the actual issue.

Took the opportunity to include a few minor tweaks related @defer following @glasser comments on #1958 (mostly adding a missing unit test and making sure we match recent spec updates, but no functional changes otherwise).

@netlify
Copy link

netlify bot commented Aug 25, 2022

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

Visit the deploys page to approve it

Name Link
🔨 Latest commit e4acca8

@pcmanus pcmanus self-assigned this Aug 25, 2022
@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 25, 2022

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.

@@ -1128,15 +1128,16 @@ const graphQLBuiltInDirectivesSpecifications: readonly DirectiveSpecification[]
locations: [DirectiveLocation.SCALAR],
argumentFct: (schema) => ({ args: [{ name: 'url', type: new NonNullType(schema.stringType()) }], errors: [] })
}),
// TODO: currently inconditionally adding @defer as the list of built-in. It's probably fine, but double check if we want to not do so when @defer-support is
// not enabled or something (it would probably be hard to handle it at that point anyway but well...).
// Note that @defer and @stream a inconditionally added to `Schema` even if they are technically "optional" built-in. _But_,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Note that @defer and @stream a inconditionally added to `Schema` even if they are technically "optional" built-in. _But_,
// Note that @defer and @stream are unconditionally added to `Schema` even if they are technically "optional" built-in. _But_,

Sylvain Lebresne added 5 commits August 29, 2022 18:49
This address most of the comment from @glasser on apollographql#1958, namely:
- it removes/update some outdated TODOs.
- it fixup the definition of @defer/@stream to match current spec.
- makes serialized query plan for condition hopefully a tad easier to
  parse (solely impact unit tests readability).
- adds a test to ensure that if the same field is queries both "normally"
  and deferred, we do query it twice (that's what spec specifies).
@pcmanus pcmanus merged commit d5fb1f8 into apollographql:main Aug 29, 2022
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.

None yet

2 participants