File tree Expand file tree Collapse file tree 3 files changed +16
-0
lines changed
main/java/graphql/schema/impl Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ public static void replaceTypeReferences(GraphQLSchema schema) {
100100 final Map <String , GraphQLNamedType > typeMap = schema .getTypeMap ();
101101 List <GraphQLSchemaElement > roots = new ArrayList <>(typeMap .values ());
102102 roots .addAll (schema .getDirectives ());
103+ roots .addAll (schema .getSchemaAppliedDirectives ());
103104 SchemaTraverser schemaTraverser = new SchemaTraverser (schemaElement -> schemaElement .getChildrenWithTypeReferences ().getChildrenAsList ());
104105 schemaTraverser .depthFirst (new GraphQLTypeResolvingVisitor (typeMap ), roots );
105106 }
Original file line number Diff line number Diff line change 11package graphql ;
22
33import graphql .schema .Coercing ;
4+ import graphql .schema .GraphQLAppliedDirective ;
5+ import graphql .schema .GraphQLAppliedDirectiveArgument ;
46import graphql .schema .GraphQLArgument ;
57import graphql .schema .GraphQLCodeRegistry ;
68import graphql .schema .GraphQLDirective ;
@@ -315,6 +317,14 @@ public Boolean parseLiteral(Object input) {
315317 .type (QueryDirectiveInput ))
316318 .build ();
317319
320+ public static GraphQLAppliedDirective cacheApplied = GraphQLAppliedDirective .newDirective ()
321+ .name ("cache" )
322+ .argument (GraphQLAppliedDirectiveArgument .newArgument ()
323+ .name ("enabled" )
324+ .type (GraphQLTypeReference .typeRef (OnOff .getName ()))
325+ .valueProgrammatic ("On" ))
326+ .build ();
327+
318328 public static GraphQLCodeRegistry codeRegistry = GraphQLCodeRegistry .newCodeRegistry ()
319329 .typeResolver ("Pet" , new TypeResolverProxy ())
320330 .typeResolver ("Addressable" , new TypeResolverProxy ())
@@ -336,5 +346,6 @@ public Boolean parseLiteral(Object input) {
336346 .additionalDirective (enumValueDirective )
337347 .additionalDirective (interfaceDirective )
338348 .codeRegistry (codeRegistry )
349+ .withSchemaAppliedDirectives (cacheApplied )
339350 .build ();
340351}
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import graphql.AssertException
44import graphql.DirectivesUtil
55import graphql.NestedInputSchema
66import graphql.introspection.Introspection
7+ import graphql.schema.GraphQLAppliedDirectiveArgument
78import graphql.schema.GraphQLArgument
89import graphql.schema.GraphQLFieldDefinition
910import graphql.schema.GraphQLInputObjectType
@@ -164,12 +165,15 @@ class SchemaUtilTest extends Specification {
164165 GraphQLObjectType person = ((GraphQLObjectType ) SchemaWithReferences . getType(" Person" ))
165166 GraphQLArgument cacheEnabled = SchemaWithReferences . getDirectivesByName()
166167 .get(Cache . getName()). getArgument(" enabled" )
168+ GraphQLAppliedDirectiveArgument appliedCacheEnabled = SchemaWithReferences . getSchemaAppliedDirective(Cache . getName())
169+ .getArgument(" enabled" )
167170
168171 then :
169172 SchemaWithReferences . allTypesAsList. findIndexOf { it instanceof GraphQLTypeReference } == -1
170173 pet. types. findIndexOf { it instanceof GraphQLTypeReference } == -1
171174 person. interfaces. findIndexOf { it instanceof GraphQLTypeReference } == -1
172175 ! (cacheEnabled. getType() instanceof GraphQLTypeReference )
176+ ! (appliedCacheEnabled. getType() instanceof GraphQLTypeReference )
173177 }
174178
175179 def " all references are replaced with deprecated directiveWithArg" () {
You can’t perform that action at this time.
0 commit comments