diff --git a/src/main/java/graphql/Directives.java b/src/main/java/graphql/Directives.java index 37f2b28550..17d57f8443 100644 --- a/src/main/java/graphql/Directives.java +++ b/src/main/java/graphql/Directives.java @@ -7,6 +7,11 @@ import graphql.language.StringValue; import graphql.schema.GraphQLDirective; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import static graphql.Scalars.GraphQLBoolean; @@ -249,6 +254,57 @@ public class Directives { .definition(EXPERIMENTAL_DISABLE_ERROR_PROPAGATION_DIRECTIVE_DEFINITION) .build(); + /** + * The set of all built-in directives that are always present in a graphql schema. + * The iteration order is stable and meaningful. + */ + public static final Set BUILT_IN_DIRECTIVES; + + /** + * A map from directive name to directive for all built-in directives. + */ + public static final Map BUILT_IN_DIRECTIVES_MAP; + + static { + LinkedHashSet directives = new LinkedHashSet<>(); + directives.add(IncludeDirective); + directives.add(SkipDirective); + directives.add(DeprecatedDirective); + directives.add(SpecifiedByDirective); + directives.add(OneOfDirective); + directives.add(DeferDirective); + directives.add(ExperimentalDisableErrorPropagationDirective); + BUILT_IN_DIRECTIVES = Collections.unmodifiableSet(directives); + + LinkedHashMap map = new LinkedHashMap<>(); + for (GraphQLDirective d : BUILT_IN_DIRECTIVES) { + map.put(d.getName(), d); + } + BUILT_IN_DIRECTIVES_MAP = Collections.unmodifiableMap(map); + } + + /** + * Returns true if a directive with the provided name is a built-in directive. + * + * @param directiveName the name of the directive in question + * + * @return true if the directive is built-in, false otherwise + */ + public static boolean isBuiltInDirective(String directiveName) { + return BUILT_IN_DIRECTIVES_MAP.containsKey(directiveName); + } + + /** + * Returns true if the provided directive is a built-in directive. + * + * @param directive the directive in question + * + * @return true if the directive is built-in, false otherwise + */ + public static boolean isBuiltInDirective(GraphQLDirective directive) { + return isBuiltInDirective(directive.getName()); + } + private static Description createDescription(String s) { return new Description(s, null, false); } diff --git a/src/main/java/graphql/introspection/IntrospectionResultToSchema.java b/src/main/java/graphql/introspection/IntrospectionResultToSchema.java index 608c570909..81ae6ce928 100644 --- a/src/main/java/graphql/introspection/IntrospectionResultToSchema.java +++ b/src/main/java/graphql/introspection/IntrospectionResultToSchema.java @@ -41,7 +41,7 @@ import static graphql.Assert.assertShouldNeverHappen; import static graphql.Assert.assertTrue; import static graphql.collect.ImmutableKit.map; -import static graphql.schema.idl.DirectiveInfo.isGraphqlSpecifiedDirective; +import static graphql.Directives.isBuiltInDirective; @SuppressWarnings("unchecked") @PublicApi @@ -131,7 +131,7 @@ public Document createSchemaDefinition(Map introspectionResult) private DirectiveDefinition createDirective(Map input) { String directiveName = (String) input.get("name"); - if (isGraphqlSpecifiedDirective(directiveName)) { + if (isBuiltInDirective(directiveName)) { return null; } diff --git a/src/main/java/graphql/schema/GraphQLSchema.java b/src/main/java/graphql/schema/GraphQLSchema.java index da7a2ccde6..d8e166cc0d 100644 --- a/src/main/java/graphql/schema/GraphQLSchema.java +++ b/src/main/java/graphql/schema/GraphQLSchema.java @@ -37,7 +37,7 @@ import static graphql.collect.ImmutableKit.nonNullCopyOf; import static graphql.schema.GraphqlTypeComparators.byNameAsc; import static graphql.schema.GraphqlTypeComparators.sortTypes; -import static java.util.Arrays.asList; + /** * The schema represents the combined type system of the graphql engine. This is how the engine knows @@ -692,7 +692,6 @@ public static Builder newSchema(GraphQLSchema existingSchema) { .introspectionSchemaType(existingSchema.getIntrospectionSchemaType()) .codeRegistry(existingSchema.getCodeRegistry()) .clearAdditionalTypes() - .clearDirectives() .additionalDirectives(new LinkedHashSet<>(existingSchema.getDirectives())) .clearSchemaDirectives() .withSchemaDirectives(schemaDirectivesArray(existingSchema)) @@ -741,10 +740,7 @@ public static class Builder { private List extensionDefinitions; private String description; - // we default these in - private final Set additionalDirectives = new LinkedHashSet<>( - asList(Directives.IncludeDirective, Directives.SkipDirective) - ); + private final Set additionalDirectives = new LinkedHashSet<>(); private final Set additionalTypes = new LinkedHashSet<>(); private final List schemaDirectives = new ArrayList<>(); private final List schemaAppliedDirectives = new ArrayList<>(); @@ -862,12 +858,6 @@ public Builder additionalDirective(GraphQLDirective additionalDirective) { return this; } - public Builder clearDirectives() { - this.additionalDirectives.clear(); - return this; - } - - public Builder withSchemaDirectives(GraphQLDirective... directives) { for (GraphQLDirective directive : directives) { withSchemaDirective(directive); @@ -960,13 +950,8 @@ private GraphQLSchema buildImpl() { assertNotNull(additionalTypes, "additionalTypes can't be null"); assertNotNull(additionalDirectives, "additionalDirectives can't be null"); - // schemas built via the schema generator have the deprecated directive BUT we want it present for hand built - // schemas - it's inherently part of the spec! - addBuiltInDirective(Directives.DeprecatedDirective, additionalDirectives); - addBuiltInDirective(Directives.SpecifiedByDirective, additionalDirectives); - addBuiltInDirective(Directives.OneOfDirective, additionalDirectives); - addBuiltInDirective(Directives.DeferDirective, additionalDirectives); - addBuiltInDirective(Directives.ExperimentalDisableErrorPropagationDirective, additionalDirectives); + // built-in directives are always present in a schema and come first + ensureBuiltInDirectives(); // quick build - no traversing final GraphQLSchema partiallyBuiltSchema = new GraphQLSchema(this); @@ -989,10 +974,21 @@ private GraphQLSchema buildImpl() { return validateSchema(finalSchema); } - private void addBuiltInDirective(GraphQLDirective qlDirective, Set additionalDirectives1) { - if (additionalDirectives1.stream().noneMatch(d -> d.getName().equals(qlDirective.getName()))) { - additionalDirectives1.add(qlDirective); + private void ensureBuiltInDirectives() { + // put built-in directives first, preserving user-supplied overrides by name + Set userDirectiveNames = new LinkedHashSet<>(); + for (GraphQLDirective d : additionalDirectives) { + userDirectiveNames.add(d.getName()); + } + LinkedHashSet ordered = new LinkedHashSet<>(); + for (GraphQLDirective builtIn : Directives.BUILT_IN_DIRECTIVES) { + if (!userDirectiveNames.contains(builtIn.getName())) { + ordered.add(builtIn); + } } + ordered.addAll(additionalDirectives); + additionalDirectives.clear(); + additionalDirectives.addAll(ordered); } private GraphQLSchema validateSchema(GraphQLSchema graphQLSchema) { diff --git a/src/main/java/graphql/schema/GraphQLTypeUtil.java b/src/main/java/graphql/schema/GraphQLTypeUtil.java index e3a6e58d89..2c318c8ae3 100644 --- a/src/main/java/graphql/schema/GraphQLTypeUtil.java +++ b/src/main/java/graphql/schema/GraphQLTypeUtil.java @@ -3,7 +3,7 @@ import graphql.Assert; import graphql.PublicApi; import graphql.introspection.Introspection; -import graphql.schema.idl.DirectiveInfo; +import graphql.Directives; import graphql.schema.idl.ScalarInfo; import java.util.Stack; @@ -293,7 +293,7 @@ public static Predicate isSystemElement() { return ScalarInfo.isGraphqlSpecifiedScalar((GraphQLScalarType) schemaElement); } if (schemaElement instanceof GraphQLDirective) { - return DirectiveInfo.isGraphqlSpecifiedDirective((GraphQLDirective) schemaElement); + return Directives.isBuiltInDirective((GraphQLDirective) schemaElement); } if (schemaElement instanceof GraphQLNamedType) { return Introspection.isIntrospectionTypes((GraphQLNamedType) schemaElement); diff --git a/src/main/java/graphql/schema/diffing/SchemaGraphFactory.java b/src/main/java/graphql/schema/diffing/SchemaGraphFactory.java index 37ac8d5e31..926d1a4e3f 100644 --- a/src/main/java/graphql/schema/diffing/SchemaGraphFactory.java +++ b/src/main/java/graphql/schema/diffing/SchemaGraphFactory.java @@ -6,7 +6,7 @@ import graphql.introspection.Introspection; import graphql.language.AstPrinter; import graphql.schema.*; -import graphql.schema.idl.DirectiveInfo; +import graphql.Directives; import graphql.schema.idl.ScalarInfo; import graphql.util.TraversalControl; import graphql.util.Traverser; @@ -390,7 +390,7 @@ private void newDirective(GraphQLDirective directive, SchemaGraph schemaGraph) { directiveVertex.add("name", directive.getName()); directiveVertex.add("repeatable", directive.isRepeatable()); directiveVertex.add("locations", directive.validLocations()); - boolean graphqlSpecified = DirectiveInfo.isGraphqlSpecifiedDirective(directive.getName()); + boolean graphqlSpecified = Directives.isBuiltInDirective(directive.getName()); directiveVertex.setBuiltInType(graphqlSpecified); directiveVertex.add("description", desc(directive.getDescription())); for (GraphQLArgument argument : directive.getArguments()) { diff --git a/src/main/java/graphql/schema/idl/DirectiveInfo.java b/src/main/java/graphql/schema/idl/DirectiveInfo.java deleted file mode 100644 index 9b8317f97e..0000000000 --- a/src/main/java/graphql/schema/idl/DirectiveInfo.java +++ /dev/null @@ -1,61 +0,0 @@ -package graphql.schema.idl; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import graphql.Directives; -import graphql.PublicApi; -import graphql.schema.GraphQLDirective; - -import java.util.Map; -import java.util.Set; - -/** - * Info on all the directives provided by graphql specification - */ -@PublicApi -public class DirectiveInfo { - - - /** - * A map from directive name to directive which provided by specification - */ - public static final Map GRAPHQL_SPECIFICATION_DIRECTIVE_MAP = ImmutableMap.of( - Directives.IncludeDirective.getName(), Directives.IncludeDirective, - Directives.SkipDirective.getName(), Directives.SkipDirective, - Directives.DeprecatedDirective.getName(), Directives.DeprecatedDirective, - Directives.SpecifiedByDirective.getName(), Directives.SpecifiedByDirective, - Directives.OneOfDirective.getName(), Directives.OneOfDirective, - // technically this is NOT yet in spec - but it is added by default by graphql-java so we include it - // we should also do @defer at some future time soon - Directives.DeferDirective.getName(), Directives.DeferDirective, - Directives.ExperimentalDisableErrorPropagationDirective.getName(), Directives.ExperimentalDisableErrorPropagationDirective - ); - /** - * A set of directives which provided by graphql specification - */ - public static final Set GRAPHQL_SPECIFICATION_DIRECTIVES =ImmutableSet.copyOf(GRAPHQL_SPECIFICATION_DIRECTIVE_MAP.values()); - - /** - * Returns true if a directive with provided directiveName has been defined in graphql specification - * - * @param directiveName the name of directive in question - * - * @return true if the directive provided by graphql specification, and false otherwise - */ - public static boolean isGraphqlSpecifiedDirective(String directiveName) { - return GRAPHQL_SPECIFICATION_DIRECTIVE_MAP.containsKey(directiveName); - } - - /** - * Returns true if the provided directive has been defined in graphql specification - * - * @param graphQLDirective the directive in question - * - * @return true if the directive provided by graphql specification, and false otherwise - */ - public static boolean isGraphqlSpecifiedDirective(GraphQLDirective graphQLDirective) { - return isGraphqlSpecifiedDirective(graphQLDirective.getName()); - } - - -} diff --git a/src/main/java/graphql/schema/idl/SchemaPrinter.java b/src/main/java/graphql/schema/idl/SchemaPrinter.java index cafa142e0c..b199926588 100644 --- a/src/main/java/graphql/schema/idl/SchemaPrinter.java +++ b/src/main/java/graphql/schema/idl/SchemaPrinter.java @@ -1,6 +1,7 @@ package graphql.schema.idl; import graphql.Assert; +import graphql.Directives; import graphql.DirectivesUtil; import graphql.GraphQLContext; import graphql.PublicApi; @@ -64,6 +65,7 @@ import java.util.stream.Stream; import static graphql.Directives.DeprecatedDirective; +import static graphql.Directives.SpecifiedByDirective; import static graphql.Scalars.GraphQLString; import static graphql.schema.visibility.DefaultGraphqlFieldVisibility.DEFAULT_FIELD_VISIBILITY; import static graphql.util.EscapeUtil.escapeJsonString; @@ -80,7 +82,7 @@ public class SchemaPrinter { * This predicate excludes all directives which are specified by the GraphQL Specification. * Printing these directives is optional. */ - public static final Predicate ExcludeGraphQLSpecifiedDirectivesPredicate = d -> !DirectiveInfo.isGraphqlSpecifiedDirective(d); + public static final Predicate ExcludeGraphQLSpecifiedDirectivesPredicate = d -> !Directives.isBuiltInDirective(d); /** * Options to use when printing a schema @@ -559,7 +561,12 @@ private SchemaElementPrinter scalarPrinter() { printAsAst(out, type.getDefinition(), type.getExtensionDefinitions()); } else { printComments(out, type, ""); - out.format("scalar %s%s\n\n", type.getName(), directivesString(GraphQLScalarType.class, type)); + List directives = DirectivesUtil.toAppliedDirectives(type).stream() + .filter(d -> !d.getName().equals(SpecifiedByDirective.getName())) + .collect(toList()); + out.format("scalar %s%s%s\n\n", type.getName(), + directivesString(GraphQLScalarType.class, directives), + specifiedByUrlString(type)); } } }; @@ -1103,6 +1110,14 @@ private String getDeprecationReason(GraphQLDirectiveContainer directiveContainer } } + private String specifiedByUrlString(GraphQLScalarType scalarType) { + String url = scalarType.getSpecifiedByUrl(); + if (url == null || !options.getIncludeDirective().test(SpecifiedByDirective.getName())) { + return ""; + } + return " @specifiedBy(url : \"" + escapeJsonString(url) + "\")"; + } + private String directiveDefinition(GraphQLDirective directive) { StringBuilder sb = new StringBuilder(); diff --git a/src/main/java/graphql/schema/usage/SchemaUsage.java b/src/main/java/graphql/schema/usage/SchemaUsage.java index 25ed7fb24c..32ac6c42c6 100644 --- a/src/main/java/graphql/schema/usage/SchemaUsage.java +++ b/src/main/java/graphql/schema/usage/SchemaUsage.java @@ -11,7 +11,7 @@ import graphql.schema.GraphQLNamedType; import graphql.schema.GraphQLObjectType; import graphql.schema.GraphQLSchema; -import graphql.schema.idl.DirectiveInfo; +import graphql.Directives; import graphql.schema.idl.ScalarInfo; import java.util.HashSet; @@ -180,7 +180,7 @@ private boolean isReferencedImpl(GraphQLSchema schema, String elementName, Set context) { - if (DirectiveInfo.isGraphqlSpecifiedDirective(graphQLDirective.getName())) { + if (Directives.isBuiltInDirective(graphQLDirective.getName())) { return TraversalControl.ABORT; } String newName = assertNotNull(newNameMap.get(graphQLDirective)); @@ -282,7 +281,7 @@ public TraversalControl visitGraphQLAppliedDirective(GraphQLAppliedDirective gra changeNode(context, newElement); return TraversalControl.ABORT; } - if (DirectiveInfo.isGraphqlSpecifiedDirective(graphQLDirective.getName())) { + if (Directives.isBuiltInDirective(graphQLDirective.getName())) { return TraversalControl.ABORT; } String newName = assertNotNull(newNameMap.get(graphQLDirective)); @@ -516,7 +515,7 @@ public TraversalControl visitGraphQLAppliedDirectiveArgument(GraphQLAppliedDirec @Override public TraversalControl visitGraphQLDirective(GraphQLDirective graphQLDirective, TraverserContext context) { - if (DirectiveInfo.isGraphqlSpecifiedDirective(graphQLDirective)) { + if (Directives.isBuiltInDirective(graphQLDirective)) { return TraversalControl.ABORT; } recordDirectiveName.accept(graphQLDirective); @@ -525,7 +524,7 @@ public TraversalControl visitGraphQLDirective(GraphQLDirective graphQLDirective, @Override public TraversalControl visitGraphQLAppliedDirective(GraphQLAppliedDirective graphQLAppliedDirective, TraverserContext context) { - if (DirectiveInfo.isGraphqlSpecifiedDirective(graphQLAppliedDirective.getName())) { + if (Directives.isBuiltInDirective(graphQLAppliedDirective.getName())) { return TraversalControl.ABORT; } recordDirectiveName.accept(graphQLAppliedDirective); diff --git a/src/test/groovy/graphql/archunit/JSpecifyAnnotationsCheck.groovy b/src/test/groovy/graphql/archunit/JSpecifyAnnotationsCheck.groovy index 95dc0cc435..8d09336874 100644 --- a/src/test/groovy/graphql/archunit/JSpecifyAnnotationsCheck.groovy +++ b/src/test/groovy/graphql/archunit/JSpecifyAnnotationsCheck.groovy @@ -286,7 +286,6 @@ class JSpecifyAnnotationsCheck extends Specification { "graphql.schema.diff.reporting.PrintStreamReporter", "graphql.schema.diffing.SchemaGraph", "graphql.schema.idl.CombinedWiringFactory", - "graphql.schema.idl.DirectiveInfo", "graphql.schema.idl.MapEnumValuesProvider", "graphql.schema.idl.NaturalEnumValuesProvider", "graphql.schema.idl.RuntimeWiring", diff --git a/src/test/groovy/graphql/introspection/IntrospectionWithDirectivesSupportTest.groovy b/src/test/groovy/graphql/introspection/IntrospectionWithDirectivesSupportTest.groovy index 591a44146e..d78bb30952 100644 --- a/src/test/groovy/graphql/introspection/IntrospectionWithDirectivesSupportTest.groovy +++ b/src/test/groovy/graphql/introspection/IntrospectionWithDirectivesSupportTest.groovy @@ -90,9 +90,9 @@ class IntrospectionWithDirectivesSupportTest extends Specification { def schemaType = er.data["__schema"] schemaType["directives"] == [ - [name: "include"], [name: "skip"], [name: "example"], [name: "secret"], - [name: "noDefault"], [name: "deprecated"], [name: "specifiedBy"], [name: "oneOf"], - [name: "defer"], [name: "experimental_disableErrorPropagation"] + [name: "include"], [name: "skip"], [name: "defer"], [name: "experimental_disableErrorPropagation"], + [name: "example"], [name: "secret"], [name: "noDefault"], + [name: "deprecated"], [name: "specifiedBy"], [name: "oneOf"] ] schemaType["appliedDirectives"] == [[name: "example", args: [[name: "argName", value: '"onSchema"']]]] @@ -174,8 +174,8 @@ class IntrospectionWithDirectivesSupportTest extends Specification { def definedDirectives = er.data["__schema"]["directives"] // secret is filter out - definedDirectives == [[name: "include"], [name: "skip"], [name: "example"], [name: "deprecated"], [name: "specifiedBy"], [name: "oneOf"], - [name: "defer"], [name: "experimental_disableErrorPropagation"] + definedDirectives == [[name: "include"], [name: "skip"], [name: "defer"], [name: "experimental_disableErrorPropagation"], + [name: "example"], [name: "deprecated"], [name: "specifiedBy"], [name: "oneOf"] ] } diff --git a/src/test/groovy/graphql/schema/GraphQLSchemaTest.groovy b/src/test/groovy/graphql/schema/GraphQLSchemaTest.groovy index a3e5d624e2..f331d1d201 100644 --- a/src/test/groovy/graphql/schema/GraphQLSchemaTest.groovy +++ b/src/test/groovy/graphql/schema/GraphQLSchemaTest.groovy @@ -148,28 +148,25 @@ class GraphQLSchemaTest extends Specification { ((Directive) newSchema.extensionDefinitions.first().getDirectives().first()).name == "pizza" } - def "clear directives works as expected"() { + def "all built-in directives are always present"() { setup: def schemaBuilder = basicSchemaBuilder() - when: "no additional directives have been specified" + when: "a schema is built" def schema = schemaBuilder.build() - then: + then: "all 7 built-in directives are present" schema.directives.size() == 7 - - when: "clear directives is called" - schema = schemaBuilder.clearDirectives().build() - then: - schema.directives.size() == 5 // @deprecated and @specifiedBy and @oneOf et al is ALWAYS added if missing - - when: "clear directives is called with more directives" - schema = schemaBuilder.clearDirectives().additionalDirective(Directives.SkipDirective).build() - then: - schema.directives.size() == 6 + schema.getDirective("include") != null + schema.getDirective("skip") != null + schema.getDirective("deprecated") != null + schema.getDirective("specifiedBy") != null + schema.getDirective("oneOf") != null + schema.getDirective("defer") != null + schema.getDirective("experimental_disableErrorPropagation") != null when: "the schema is transformed, things are copied" - schema = schema.transform({ builder -> builder.additionalDirective(Directives.IncludeDirective) }) - then: + schema = schema.transform({ builder -> builder }) + then: "all 7 built-in directives are still present" schema.directives.size() == 7 } diff --git a/src/test/groovy/graphql/schema/SchemaTransformerTest.groovy b/src/test/groovy/graphql/schema/SchemaTransformerTest.groovy index ebe47ad2c4..bf0279755c 100644 --- a/src/test/groovy/graphql/schema/SchemaTransformerTest.groovy +++ b/src/test/groovy/graphql/schema/SchemaTransformerTest.groovy @@ -1464,4 +1464,53 @@ type Rental { e.getMessage().contains("All types within a GraphQL schema must have unique names") e.getMessage().contains("ExistingType") } + + def "can modify a built-in directive via schema transformation"() { + given: + GraphQLSchema schema = TestUtil.schema(""" + type Query { + hello: String @deprecated(reason: "use goodbye") + goodbye: String + } + """) + + when: + GraphQLSchema newSchema = SchemaTransformer.transformSchema(schema, new GraphQLTypeVisitorStub() { + @Override + TraversalControl visitGraphQLDirective(GraphQLDirective node, TraverserContext context) { + if (node.getName() == "deprecated") { + def changedNode = node.transform({ builder -> + builder.argument(GraphQLArgument.newArgument() + .name("deletionDate") + .type(Scalars.GraphQLString) + .description("The date when this field will be removed")) + }) + return changeNode(context, changedNode) + } + return TraversalControl.CONTINUE + } + }) + + then: "the modified built-in directive has the new argument" + def deprecatedDirective = newSchema.getDirective("deprecated") + deprecatedDirective != null + deprecatedDirective.getArguments().size() == 2 + deprecatedDirective.getArgument("reason") != null + deprecatedDirective.getArgument("deletionDate") != null + deprecatedDirective.getArgument("deletionDate").getType() == Scalars.GraphQLString + + and: "other built-in directives remain unchanged" + newSchema.getDirective("include").getArguments().size() == 1 + newSchema.getDirective("skip").getArguments().size() == 1 + + and: "all built-in directives are still present" + newSchema.getDirective("include") != null + newSchema.getDirective("skip") != null + newSchema.getDirective("deprecated") != null + newSchema.getDirective("specifiedBy") != null + newSchema.getDirective("oneOf") != null + newSchema.getDirective("defer") != null + newSchema.getDirective("experimental_disableErrorPropagation") != null + newSchema.getDirectives().size() == schema.getDirectives().size() + } } diff --git a/src/test/groovy/graphql/util/AnonymizerTest.groovy b/src/test/groovy/graphql/util/AnonymizerTest.groovy index 6865879f55..ae6ed614a4 100644 --- a/src/test/groovy/graphql/util/AnonymizerTest.groovy +++ b/src/test/groovy/graphql/util/AnonymizerTest.groovy @@ -2,7 +2,7 @@ package graphql.util import graphql.AssertException import graphql.TestUtil -import graphql.schema.idl.DirectiveInfo +import graphql.Directives import graphql.schema.idl.SchemaPrinter import spock.lang.Specification @@ -718,7 +718,7 @@ type Object1 { when: def result = Anonymizer.anonymizeSchema(schema) def newSchema = new SchemaPrinter(SchemaPrinter.Options.defaultOptions() - .includeDirectives({!DirectiveInfo.isGraphqlSpecifiedDirective(it) || it == "deprecated"})) + .includeDirectives({!Directives.isBuiltInDirective(it) || it == "deprecated"})) .print(result) then: