Directive validation is now done on schema build post validation#2576
Merged
Directive validation is now done on schema build post validation#2576
Conversation
bbakerman
commented
Oct 8, 2021
| 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); | ||
| } | ||
|
|
Member
Author
There was a problem hiding this comment.
None of this applies any more - it will be done at Schema validation time when we have everything
bbakerman
commented
Oct 8, 2021
| 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.
rename of internal method
bbakerman
commented
Oct 8, 2021
| 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.
No longer needed this will be checked later at schema build time
bbakerman
commented
Oct 8, 2021
|
|
||
| checkNamedUniqueness(errors, nonRepeatableDirectives, Directive::getName, | ||
| (directiveName, directive) -> new NonUniqueDirectiveError(typeDefinition, fieldDefinition, directiveName)); | ||
| } |
Member
Author
There was a problem hiding this comment.
no longer needed - checked at schema build time
bbakerman
commented
Oct 8, 2021
| .additionalDirective(enumDirective) | ||
| .additionalDirective(enumValueDirective) | ||
| .additionalDirective(interfaceDirective) | ||
|
|
Member
Author
There was a problem hiding this comment.
fixed up - this was invalid - that is there was a directive used but it was not named in the schema
bbakerman
commented
Oct 8, 2021
| then: | ||
| thrown(AssertException) | ||
|
|
||
|
|
Member
Author
There was a problem hiding this comment.
no longer done in get calls - they are KNOWN to be valid now
bbakerman
commented
Oct 9, 2021
| private static GraphQLDirective serialisedToDirective; | ||
|
|
||
| static { | ||
| serialisedToDirective = newDirective() |
Member
Author
There was a problem hiding this comment.
We now require that the directive definition be present in the schema
andimarek
approved these changes
Oct 26, 2021
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
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.
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