-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[RFC] Added support for repeatable directives #1541
Closed
Closed
Changes from 12 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
cab37c7
[RFC] Added support for repeatable directives
OlegIlyenko ea40e38
Merge branch 'master' into repeatable-directives
OlegIlyenko 7eb1fd7
Updated with the most recent changes
OlegIlyenko 8cd0e52
Adjusted json formatting
OlegIlyenko 77f85b3
Skip unknown directives + other improvements based on the review comm…
OlegIlyenko 20deb26
Test for unknown directives
OlegIlyenko 1180d92
Added support for repeatable directives in `extendSchema`
OlegIlyenko f8378d0
Added `DIRECTIVE_REPEATABLE_REMOVED` breaking change
OlegIlyenko 3b5bf03
Skip `repeatable` flag by default in the introspection.
OlegIlyenko 3a7fafa
`repeatable` flag in the introspection results is now optional
OlegIlyenko ae9e7f9
Use `uniqueDirectiveMap` instead of `repeatableMap`
OlegIlyenko 56fee7d
Rename `repeatable` → `isRepeatable`
OlegIlyenko 0dff21f
Updated `UniqueDirectivesPerLocation` validation docs
OlegIlyenko 1a07bd9
Merge branch 'master' into repeatable-directives
OlegIlyenko 89f5780
Use name `repeatable` instead of `isRepeatable` in all places except …
OlegIlyenko 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 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 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 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 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 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 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 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 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 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 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 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
Oops, something went wrong.
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.
I wonder if this should be:
If someone never uses repeatable directives, this adds no extra weight to the node.
I also don't think we need the
is
prefix: the fact that it's a boolean is enough information, and the questionrepeatable? false
is close-to-valid English as-is (just as understandable asis repeatable? false
).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.
The
is
prefix primarily added for consistency withisDeprecated
, as @IvanGoncharov pointed out https://github.com/facebook/graphql/pull/472/files/1ba4e196aa710a10eceaa346d02a970dfd0b2d3a#diff-35fb422eded6e8f4df638c0d159008f6I think I would prefer it keep it mandatory. This makes it easier to work with and i feel that the performance overhead is negligible. But I can also make it optional.
WDYT?
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.
@OlegIlyenko In the context of AST, I'm more in favor of @mjmahone proposal since we already have
block
with similar prototype:graphql-js/src/language/ast.js
Line 320 in 0dff21f
Plus it looks like JS AST doesn't use
is
prefix, e.g.async
:https://github.com/estree/estree/blob/df2290b23a652e1ec354b6775459a3b42e22f108/es2017.md#function
But outside of AST I strongly believe it should be named
isRepeatable
for the consistency withisDeprecated
.I'm with you on that point especially since JS parser always preserve boolean flags and they typically work with way bigger files than GraphQL.
Also defacto (in our parser) we always provide values for all keys so why should Flow typings mark that as optional.
That said I think it's outside of scope of this PR and should be disscussed for AST as a whole and not for individual flags.
So for now I think it should be optional.
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.
I think both alternatives should be fine. I also considered keep
repeatable
name on AST nodes, but then renamed it withis
prefix across the whole codebase for the sake of the naming consistency.But I think it should totally fine to have
repeatable
field on AST node and then useisRepeatable
everywhere else. @mjmahone What do you think?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.
I renamed
isRepeatable
back torepeatable
in all places except introspection: 89f5780