-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Directive validation is now done on schema build post validation #2576
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
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,6 @@ | |
|
|
||
| import static graphql.Assert.assertNotNull; | ||
| import static graphql.Assert.assertValidName; | ||
| import static graphql.schema.GraphqlTypeComparators.asIsOrder; | ||
| import static graphql.schema.GraphqlTypeComparators.sortTypes; | ||
| import static graphql.util.FpKit.getByName; | ||
| import static graphql.util.FpKit.valuesToList; | ||
|
|
@@ -262,7 +261,7 @@ public Builder(GraphQLInterfaceType existing) { | |
| this.extensionDefinitions = existing.getExtensionDefinitions(); | ||
| this.fields.putAll(getByName(existing.getFieldDefinitions(), GraphQLFieldDefinition::getName)); | ||
| this.interfaces.putAll(getByName(existing.originalInterfaces, GraphQLNamedType::getName)); | ||
| DirectivesUtil.enforceAddAll(this.directives,existing.getDirectives()); | ||
| DirectivesUtil.addAll(this.directives,existing.getDirectives()); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -376,14 +375,14 @@ public Builder withDirectives(GraphQLDirective... directives) { | |
|
|
||
| public Builder withDirective(GraphQLDirective directive) { | ||
| assertNotNull(directive, () -> "directive can't be null"); | ||
| DirectivesUtil.enforceAdd(this.directives, directive); | ||
| DirectivesUtil.add(this.directives, directive); | ||
| return this; | ||
| } | ||
|
|
||
| public Builder replaceDirectives(List<GraphQLDirective> directives) { | ||
| assertNotNull(directives, () -> "directive can't be null"); | ||
| this.directives.clear(); | ||
| DirectivesUtil.enforceAddAll(this.directives, directives); | ||
| DirectivesUtil.addAll(this.directives, directives); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename of internal method |
||
| return this; | ||
| } | ||
|
|
||
|
|
||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| package graphql.schema.idl; | ||
|
|
||
| import graphql.Assert; | ||
| import graphql.AssertException; | ||
| import graphql.Internal; | ||
| import graphql.introspection.Introspection.DirectiveLocation; | ||
|
|
@@ -257,10 +256,6 @@ String buildDeprecationReason(List<Directive> directives) { | |
|
|
||
| private GraphQLDirective buildAppliedDirective(BuildContext buildCtx, Directive directive, DirectiveLocation directiveLocation, Set<GraphQLDirective> runtimeDirectives, GraphqlTypeComparatorRegistry comparatorRegistry, Set<String> previousNames) { | ||
| GraphQLDirective gqlDirective = buildAppliedDirective(buildCtx, directive, runtimeDirectives, directiveLocation, comparatorRegistry); | ||
| if (previousNames.contains(directive.getName())) { | ||
| // other parts of the code protect against duplicate non repeatable directives | ||
| Assert.assertTrue(gqlDirective.isRepeatable(), () -> String.format("The directive '%s' MUST be defined as a repeatable directive if its repeated on an SDL element", directive.getName())); | ||
| } | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No longer needed this will be checked later at schema build time |
||
| previousNames.add(gqlDirective.getName()); | ||
| return gqlDirective; | ||
| } | ||
|
|
@@ -302,7 +297,7 @@ private GraphQLArgument buildAppliedDArgument(BuildContext buildCtx, Argument ar | |
| builder.name(arg.getName()) | ||
| .type(inputType) | ||
| .definition(buildCtx.isCaptureAstDefinitions() ? directiveDefArgument.getDefinition() : null); | ||
|
|
||
| // we know it is a literal because it was created by SchemaGenerator | ||
| if (directiveDefArgument.getArgumentDefaultValue().isSet()) { | ||
| builder.defaultValueLiteral((Value) directiveDefArgument.getArgumentDefaultValue().getValue()); | ||
|
|
||
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.
None of this applies any more - it will be done at Schema validation time when we have everything