-
Notifications
You must be signed in to change notification settings - Fork 254
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
👷 Deploy request for apollo-federation-docs pending review.Visit the deploys page to approve it
|
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
force-pushed
the
defer-fragment-issue
branch
from
August 26, 2022 08:29
ff3e395
to
4a69ede
Compare
clenfest
approved these changes
Aug 29, 2022
internals-js/src/definitions.ts
Outdated
@@ -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_, |
There was a problem hiding this comment.
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_, |
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
force-pushed
the
defer-fragment-issue
branch
from
August 29, 2022 16:50
4a69ede
to
e4acca8
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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).