Skip to content

Commit 0a1559b

Browse files
committed
Update anonymizer
1 parent 017f8ac commit 0a1559b

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

src/main/java/graphql/util/Anonymizer.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
import graphql.schema.GraphQLTypeVisitor;
7171
import graphql.schema.GraphQLTypeVisitorStub;
7272
import graphql.schema.GraphQLUnionType;
73+
import graphql.schema.InputValueWithState;
7374
import graphql.schema.SchemaTransformer;
7475
import graphql.schema.TypeResolver;
7576
import graphql.schema.idl.DirectiveInfo;
@@ -94,6 +95,7 @@
9495
import static graphql.Assert.assertNotNull;
9596
import static graphql.parser.ParserEnvironment.newParserEnvironment;
9697
import static graphql.schema.GraphQLArgument.newArgument;
98+
import static graphql.schema.GraphQLNonNull.nonNull;
9799
import static graphql.schema.GraphQLTypeUtil.unwrapNonNull;
98100
import static graphql.schema.GraphQLTypeUtil.unwrapNonNullAs;
99101
import static graphql.schema.GraphQLTypeUtil.unwrapOneAs;
@@ -260,16 +262,6 @@ public TraversalControl visitGraphQLFieldDefinition(GraphQLFieldDefinition graph
260262

261263
@Override
262264
public TraversalControl visitGraphQLDirective(GraphQLDirective graphQLDirective, TraverserContext<GraphQLSchemaElement> context) {
263-
if (Directives.DEPRECATED_DIRECTIVE_DEFINITION.getName().equals(graphQLDirective.getName())) {
264-
GraphQLArgument reason = newArgument().name("reason")
265-
.type(Scalars.GraphQLString)
266-
.clearValue().build();
267-
GraphQLDirective newElement = graphQLDirective.transform(builder -> {
268-
builder.description(null).argument(reason);
269-
});
270-
changeNode(context, newElement);
271-
return TraversalControl.ABORT;
272-
}
273265
if (DirectiveInfo.isGraphqlSpecifiedDirective(graphQLDirective.getName())) {
274266
return TraversalControl.ABORT;
275267
}
@@ -285,7 +277,8 @@ public TraversalControl visitGraphQLAppliedDirective(GraphQLAppliedDirective gra
285277
if (Directives.DEPRECATED_DIRECTIVE_DEFINITION.getName().equals(graphQLDirective.getName())) {
286278
GraphQLAppliedDirectiveArgument reason = GraphQLAppliedDirectiveArgument.newArgument().name("reason")
287279
.type(Scalars.GraphQLString)
288-
.clearValue().build();
280+
.clearValue()
281+
.build();
289282
GraphQLAppliedDirective newElement = graphQLDirective.transform(builder -> {
290283
builder.description(null).argument(reason);
291284
});
@@ -918,7 +911,7 @@ private static GraphQLType fromTypeToGraphQLType(Type type, GraphQLSchema schema
918911
graphql.Assert.assertNotNull(graphQLType, "Schema must contain type %s", typeName);
919912
return graphQLType;
920913
} else if (type instanceof NonNullType) {
921-
return GraphQLNonNull.nonNull(fromTypeToGraphQLType(TypeUtil.unwrapOne(type), schema));
914+
return nonNull(fromTypeToGraphQLType(TypeUtil.unwrapOne(type), schema));
922915
} else if (type instanceof ListType) {
923916
return GraphQLList.list(fromTypeToGraphQLType(TypeUtil.unwrapOne(type), schema));
924917
} else {

src/test/groovy/graphql/util/AnonymizerTest.groovy

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,8 +729,12 @@ type Object1 {
729729
730730
directive @Directive1(argument1: String! = "stringValue4") repeatable on SCHEMA | SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINITION | INTERFACE | UNION | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION
731731
732-
directive @deprecated(reason: String!) on FIELD_DEFINITION | ARGUMENT_DEFINITION | ENUM_VALUE | INPUT_FIELD_DEFINITION
733-
732+
"Marks the field, argument, input field or enum value as deprecated"
733+
directive @deprecated(
734+
"The reason for the deprecation"
735+
reason: String! = "No longer supported"
736+
) on FIELD_DEFINITION | ARGUMENT_DEFINITION | ENUM_VALUE | INPUT_FIELD_DEFINITION
737+
734738
interface Interface1 @Directive1(argument1 : "stringValue12") {
735739
field2: String
736740
field3: Enum1

0 commit comments

Comments
 (0)