-
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
Conversation
| Assert.assertTrue(isAllNonRepeatable(directiveList), () -> String.format("'%s' is a repeatable directive and you have used a non repeatable access method", directiveName)); | ||
| return directiveList.get(0); | ||
| } | ||
|
|
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
| assertNotNull(directives, () -> "directive can't be null"); | ||
| this.directives.clear(); | ||
| DirectivesUtil.enforceAddAll(this.directives, directives); | ||
| DirectivesUtil.addAll(this.directives, directives); |
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.
rename of internal method
| 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())); | ||
| } |
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.
No longer needed this will be checked later at schema build time
|
|
||
| checkNamedUniqueness(errors, nonRepeatableDirectives, Directive::getName, | ||
| (directiveName, directive) -> new NonUniqueDirectiveError(typeDefinition, fieldDefinition, directiveName)); | ||
| } |
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.
no longer needed - checked at schema build time
| .additionalDirective(enumDirective) | ||
| .additionalDirective(enumValueDirective) | ||
| .additionalDirective(interfaceDirective) | ||
|
|
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.
fixed up - this was invalid - that is there was a directive used but it was not named in the schema
| then: | ||
| thrown(AssertException) | ||
|
|
||
|
|
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.
no longer done in get calls - they are KNOWN to be valid now
| private static GraphQLDirective serialisedToDirective; | ||
|
|
||
| static { | ||
| serialisedToDirective = newDirective() |
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 now require that the directive definition be present in the schema
Previously we checked at SDL parse time for repeatable directives OR we did it during programmatically adding directives
We ALSO checked during "read" that you did not ask for a repeatable directive.
This now moves that to schema build validation time. This is where we want to do this.
Also this PR is a setup towards Applied Directives - since this needs to happen in order to move to Applied Directives
#2562