-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix @skip definition is added twice to the GraphQLSchema when defined in sdl #2940
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
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.
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.
we should add all the system defined directives
@deprecated / @specfiedBy / @include / @Skip
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.
Otherwise I approve of this PR and its approach
Uh oh!
There was an error while loading. Please reload this page.
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.
It's a little different for
@deprecatedand@specifiedBy.Let me explain and tell me what you think.
@deprecatedand@specifiedByare schema directives, and the current behavior is to only add them if not present in the supplied SDL.I think this is fair since one could imagine a case where we are reading an older spec SDL and it would be nice if we can keep the spec behavior defined in the SDL (e.g deprecated locations missing the enum location on older version of the spec) although not super important in my opinion since spec evolution is backward compatible, hence using the engine definitions is still OK.
Additionally
@deprecatedand@specifiedByare added in the typeRegistry rather than the GraphQLSchema.Builder since@deprecatedand@specifiedByare schema directives, and the applied directives locations should be checked while performing the registry checks.Also we could add some validation, such that if you attempt to define
@deprecatedand@specifiedByon your own, then they need to be "compatible" with the spec standard defined directives. Not super convinced we need that kind of validation, it feels a little over defensive.For
@skipand@include, they are execution (query) directives, i.e there can't be any applied directives in the schema, so they are being added by default only later in the GraphQLSchema builder. The behavior I added here "ignores" any directive in the SDL that attempts to redefines them.To make things consistent w.r.t to all standard directives, we could follow the same pattern as with deprecated and specifiedBy, meaning adding them all only if not present in the typeRegistry, but we would need to either remove them from the GraphQLSchema.Builder (potentially a behavior breaking change and this might cause problems when building a schema programmatically without a SDL) or only add them to the GraphQLSchem.Builder if not present (although there is not a good way today as GraphQLSchema.builder.additionalDirectives adds to the set even though it might share the same name so we might see double adding when a schema is merged and cloned from another schema).
Thoughts?
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.
Lets go with this for now - progress over perfection. You make a good point so lets go with it