Skip to content

Conversation

@bbakerman
Copy link
Member

@bbakerman bbakerman commented Oct 8, 2021

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

@bbakerman bbakerman requested a review from andimarek October 8, 2021 07:37
@bbakerman bbakerman added this to the 18.0 milestone 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);
}

Copy link
Member Author

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);
Copy link
Member Author

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()));
}
Copy link
Member Author

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));
}
Copy link
Member Author

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)

Copy link
Member Author

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)


Copy link
Member Author

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()
Copy link
Member Author

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

@bbakerman bbakerman changed the title WIP - this removes the schema repeating checks from pre schema build to schema post validation Directive validation is now done on schema build post validation Oct 9, 2021
@bbakerman bbakerman merged commit 5108111 into master Dec 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants