-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,7 +60,6 @@ | |
| import graphql.schema.GraphQLNamedOutputType; | ||
| import graphql.schema.GraphQLNamedSchemaElement; | ||
| import graphql.schema.GraphQLNamedType; | ||
| import graphql.schema.GraphQLNonNull; | ||
| import graphql.schema.GraphQLObjectType; | ||
| import graphql.schema.GraphQLScalarType; | ||
| import graphql.schema.GraphQLSchema; | ||
|
|
@@ -93,7 +92,7 @@ | |
|
|
||
| import static graphql.Assert.assertNotNull; | ||
| import static graphql.parser.ParserEnvironment.newParserEnvironment; | ||
| import static graphql.schema.GraphQLArgument.newArgument; | ||
| import static graphql.schema.GraphQLNonNull.nonNull; | ||
| import static graphql.schema.GraphQLTypeUtil.unwrapNonNull; | ||
| import static graphql.schema.GraphQLTypeUtil.unwrapNonNullAs; | ||
| import static graphql.schema.GraphQLTypeUtil.unwrapOneAs; | ||
|
|
@@ -260,16 +259,6 @@ public TraversalControl visitGraphQLFieldDefinition(GraphQLFieldDefinition graph | |
|
|
||
| @Override | ||
| public TraversalControl visitGraphQLDirective(GraphQLDirective graphQLDirective, TraverserContext<GraphQLSchemaElement> context) { | ||
| if (Directives.DEPRECATED_DIRECTIVE_DEFINITION.getName().equals(graphQLDirective.getName())) { | ||
| GraphQLArgument reason = newArgument().name("reason") | ||
| .type(Scalars.GraphQLString) | ||
| .clearValue().build(); | ||
| GraphQLDirective newElement = graphQLDirective.transform(builder -> { | ||
| builder.description(null).argument(reason); | ||
| }); | ||
| changeNode(context, newElement); | ||
| return TraversalControl.ABORT; | ||
| } | ||
|
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. 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 |
||
| 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())) { | ||
|
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. As I mentioned above, the censoring of |
||
| GraphQLAppliedDirectiveArgument reason = GraphQLAppliedDirectiveArgument.newArgument().name("reason") | ||
| .type(Scalars.GraphQLString) | ||
|
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. 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 |
||
| .clearValue().build(); | ||
| .clearValue() | ||
| .build(); | ||
| GraphQLAppliedDirective newElement = graphQLDirective.transform(builder -> { | ||
| builder.description(null).argument(reason); | ||
| }); | ||
|
|
@@ -918,7 +908,7 @@ private static GraphQLType fromTypeToGraphQLType(Type type, GraphQLSchema schema | |
| graphql.Assert.assertNotNull(graphQLType, "Schema must contain type %s", typeName); | ||
| return graphQLType; | ||
| } else if (type instanceof NonNullType) { | ||
| return GraphQLNonNull.nonNull(fromTypeToGraphQLType(TypeUtil.unwrapOne(type), schema)); | ||
| return nonNull(fromTypeToGraphQLType(TypeUtil.unwrapOne(type), schema)); | ||
| } else if (type instanceof ListType) { | ||
| return GraphQLList.list(fromTypeToGraphQLType(TypeUtil.unwrapOne(type), schema)); | ||
| } else { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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" | ||
|
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. All that follows is a number of tests which need updating |
||
| reason: String! = "No longer supported" | ||
| ) on FIELD_DEFINITION | ARGUMENT_DEFINITION | ENUM_VALUE | INPUT_FIELD_DEFINITION | ||
|
|
||
| directive @enumTypeDirective on ENUM | ||
|
|
@@ -1144,7 +1144,7 @@ input SomeInput { | |
| result == '''"Marks the field, argument, input field or enum value as deprecated" | ||
| directive @deprecated( | ||
| "The reason for the deprecation" | ||
| reason: String = "No longer supported" | ||
| reason: String! = "No longer supported" | ||
| ) on FIELD_DEFINITION | ARGUMENT_DEFINITION | ENUM_VALUE | INPUT_FIELD_DEFINITION | ||
|
|
||
| "Directs the executor to include this field or fragment only when the `if` argument is true" | ||
|
|
@@ -1240,7 +1240,7 @@ type Query { | |
| resultWithDirectives == '''"Marks the field, argument, input field or enum value as deprecated" | ||
| directive @deprecated( | ||
| "The reason for the deprecation" | ||
| reason: String = "No longer supported" | ||
| reason: String! = "No longer supported" | ||
| ) on FIELD_DEFINITION | ARGUMENT_DEFINITION | ENUM_VALUE | INPUT_FIELD_DEFINITION | ||
|
|
||
| directive @example on FIELD_DEFINITION | ||
|
|
@@ -1308,7 +1308,7 @@ type Query { | |
| resultWithDirectiveDefinitions == '''"Marks the field, argument, input field or enum value as deprecated" | ||
| directive @deprecated( | ||
| "The reason for the deprecation" | ||
| reason: String = "No longer supported" | ||
| reason: String! = "No longer supported" | ||
| ) on FIELD_DEFINITION | ARGUMENT_DEFINITION | ENUM_VALUE | INPUT_FIELD_DEFINITION | ||
|
|
||
| directive @example on FIELD_DEFINITION | ||
|
|
@@ -1405,7 +1405,7 @@ extend schema { | |
| "Marks the field, argument, input field or enum value as deprecated" | ||
| directive @deprecated( | ||
| "The reason for the deprecation" | ||
| reason: String = "No longer supported" | ||
| reason: String! = "No longer supported" | ||
| ) on FIELD_DEFINITION | ARGUMENT_DEFINITION | ENUM_VALUE | INPUT_FIELD_DEFINITION | ||
|
|
||
| "Directs the executor to include this field or fragment only when the `if` argument is true" | ||
|
|
@@ -1491,7 +1491,7 @@ schema @schemaDirective{ | |
| "Marks the field, argument, input field or enum value as deprecated" | ||
| directive @deprecated( | ||
| "The reason for the deprecation" | ||
| reason: String = "No longer supported" | ||
| reason: String! = "No longer supported" | ||
| ) on FIELD_DEFINITION | ARGUMENT_DEFINITION | ENUM_VALUE | INPUT_FIELD_DEFINITION | ||
|
|
||
| "Directs the executor to include this field or fragment only when the `if` argument is true" | ||
|
|
@@ -1631,7 +1631,7 @@ type MyQuery { | |
| result == '''"Marks the field, argument, input field or enum value as deprecated" | ||
| directive @deprecated( | ||
| "The reason for the deprecation" | ||
| reason: String = "No longer supported" | ||
| reason: String! = "No longer supported" | ||
| ) on FIELD_DEFINITION | ARGUMENT_DEFINITION | ENUM_VALUE | INPUT_FIELD_DEFINITION | ||
|
|
||
| directive @directive1 on SCALAR | ||
|
|
@@ -1873,7 +1873,7 @@ type Query { | |
| result == '''"Marks the field, argument, input field or enum value as deprecated" | ||
| directive @deprecated( | ||
| "The reason for the deprecation" | ||
| reason: String = "No longer supported" | ||
| reason: String! = "No longer supported" | ||
| ) on FIELD_DEFINITION | ARGUMENT_DEFINITION | ENUM_VALUE | INPUT_FIELD_DEFINITION | ||
|
|
||
| type Query { | ||
|
|
@@ -2167,7 +2167,7 @@ type PrintMeType { | |
| "Marks the field, argument, input field or enum value as deprecated" | ||
| directive @deprecated( | ||
| "The reason for the deprecation" | ||
| reason: String = "No longer supported" | ||
| reason: String! = "No longer supported" | ||
| ) on FIELD_DEFINITION | ARGUMENT_DEFINITION | ENUM_VALUE | INPUT_FIELD_DEFINITION | ||
|
|
||
| directive @foo on SCHEMA | ||
|
|
@@ -2399,7 +2399,7 @@ directive @include( | |
| "Marks the field, argument, input field or enum value as deprecated" | ||
| directive @deprecated( | ||
| "The reason for the deprecation" | ||
| reason: String = "No longer supported" | ||
| reason: String! = "No longer supported" | ||
| ) on FIELD_DEFINITION | ARGUMENT_DEFINITION | ENUM_VALUE | INPUT_FIELD_DEFINITION | ||
|
|
||
| union ZUnion = XQuery | Query | ||
|
|
@@ -2515,7 +2515,7 @@ schema { | |
| "Marks the field, argument, input field or enum value as deprecated" | ||
| directive @deprecated( | ||
| "The reason for the deprecation" | ||
| reason: String = "No longer supported" | ||
| reason: String! = "No longer supported" | ||
| ) on FIELD_DEFINITION | ARGUMENT_DEFINITION | ENUM_VALUE | INPUT_FIELD_DEFINITION | ||
|
|
||
| " custom directive 'example' description 1" | ||
|
|
@@ -2752,7 +2752,7 @@ schema { | |
| "Marks the field, argument, input field or enum value as deprecated" | ||
| directive @deprecated( | ||
| "The reason for the deprecation" | ||
| reason: String = "No longer supported" | ||
| reason: String! = "No longer supported" | ||
| ) on FIELD_DEFINITION | ARGUMENT_DEFINITION | ENUM_VALUE | INPUT_FIELD_DEFINITION | ||
|
|
||
| " custom directive 'example' description 1" | ||
|
|
@@ -2940,7 +2940,7 @@ input Input { | |
| result == """"Marks the field, argument, input field or enum value as deprecated" | ||
| directive @deprecated( | ||
| "The reason for the deprecation" | ||
| reason: String = "No longer supported" | ||
| reason: String! = "No longer supported" | ||
| ) on FIELD_DEFINITION | ARGUMENT_DEFINITION | ENUM_VALUE | INPUT_FIELD_DEFINITION | ||
|
|
||
| "Directs the executor to include this field or fragment only when the `if` argument is true" | ||
|
|
||
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