-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Make deprecated reason non-null #3759
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
Test Results 306 files 306 suites 47s ⏱️ Results for commit a95cc02. ♻️ This comment has been updated with latest results. |
}); | ||
changeNode(context, newElement); | ||
return TraversalControl.ABORT; | ||
} |
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 am guessing the Anonymizer pre-dates the split of GraphQLDirective and GraphQLAppliedDirective
Now that applied directives are separated, there shouldn't be any transformation in this GraphQLDirective
visitor method. The deprecated directive as defined in the schema should be unchanged, as any other built-in directive in the next lines
if (DirectiveInfo.isGraphqlSpecifiedDirective(graphQLDirective.getName())) {
return TraversalControl.ABORT;
}
@@ -285,7 +274,8 @@ public TraversalControl visitGraphQLAppliedDirective(GraphQLAppliedDirective gra | |||
if (Directives.DEPRECATED_DIRECTIVE_DEFINITION.getName().equals(graphQLDirective.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.
As I mentioned above, the censoring of @deprecated
reasons should actually only be here, in the GraphQLAppliedDirective
visitor method only
@@ -285,7 +274,8 @@ public TraversalControl visitGraphQLAppliedDirective(GraphQLAppliedDirective gra | |||
if (Directives.DEPRECATED_DIRECTIVE_DEFINITION.getName().equals(graphQLDirective.getName())) { | |||
GraphQLAppliedDirectiveArgument reason = GraphQLAppliedDirectiveArgument.newArgument().name("reason") | |||
.type(Scalars.GraphQLString) |
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.
It's ok for an applied directive's argument to be nullable. In this case, the default value ("No longer supported") as defined in the schema will be used
@@ -968,7 +968,7 @@ type Query { | |||
"Marks the field, argument, input field or enum value as deprecated" | |||
directive @deprecated( | |||
"The reason for the deprecation" | |||
reason: String = "No longer supported" |
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.
All that follows is a number of tests which need updating
@@ -63,7 +63,7 @@ public class Directives { | |||
newInputValueDefinition() | |||
.name("reason") | |||
.description(createDescription("The reason for the deprecation")) | |||
.type(newTypeName().name(STRING).build()) | |||
.type(newNonNullType(newTypeName().name(STRING).build()).build()) |
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.
what is newNonNullType
???
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.
ahh a builder
This proposed change has been included in the draft specification today: https://spec.graphql.org/draft/#sec--deprecated |
Closes #3736
An incoming spec change will require the
@deprecated
reason to be non-nullable. graphql/graphql-spec#1040.Whilst this is technically a breaking change, the reason already has a default value, so it is only a breaking change if the reason
null
was previously used.Update: when I started the PR it was at RFC1 stage, at the time of merging the proposal reached RFC3 (Accepted) stage and is already in the draft spec document: https://spec.graphql.org/draft/#sec--deprecated