@@ -2,27 +2,25 @@ package graphql.introspection
22
33import graphql.GraphQL
44import graphql.TestUtil
5- import graphql.schema.idl.SchemaPrinter
65import spock.lang.Specification
76
87class IntrospectionWithDirectivesSupportTest extends Specification {
98
10- def printer = new SchemaPrinter (SchemaPrinter.Options . defaultOptions(). includeIntrospectionTypes(true ))
11-
129 def " can find directives in introspection" () {
1310 def sdl = '''
1411 directive @example( argName : String = "default") on OBJECT | FIELD_DEFINITION | INPUT_OBJECT | INPUT_FIELD_DEFINITION | SCHEMA
1512 directive @secret( argName : String = "secret") on OBJECT
13+ directive @noDefault( arg1 : String, arg2 : String) on OBJECT
1614
1715 schema @example(argName : "onSchema") {
1816 query : Query
1917 }
2018
21- type Query @example(argName : "onQuery") {
19+ type Query @example(argName : "onQuery") @noDefault(arg1 : "set") {
2220 hello : Hello @deprecated
2321 }
2422
25- type Hello @example {
23+ type Hello @example @noDefault {
2624 world : String @deprecated
2725 }
2826
@@ -33,9 +31,6 @@ class IntrospectionWithDirectivesSupportTest extends Specification {
3331
3432 def schema = TestUtil . schema(sdl)
3533 schema = new IntrospectionWithDirectivesSupport (). apply(schema)
36-
37- println printer. print (schema)
38-
3934 def graphql = GraphQL . newGraphQL(schema). build()
4035
4136 def query = '''
@@ -94,15 +89,21 @@ class IntrospectionWithDirectivesSupportTest extends Specification {
9489
9590 def schemaType = er. data[" __schema" ]
9691
97- schemaType[" directives" ] == [[name : " include" ], [name : " skip" ], [name : " example" ], [name : " secret" ], [name : " deprecated" ], [name : " specifiedBy" ]]
92+ schemaType[" directives" ] == [[name : " include" ], [name : " skip" ], [name : " example" ], [name : " secret" ], [name : " noDefault " ], [ name : " deprecated" ], [name : " specifiedBy" ]]
9893
9994 schemaType[" appliedDirectives" ] == [[name : " example" , args : [[name : " argName" , value : ' "onSchema"' ]]]]
10095
10196 def queryType = er. data[" __schema" ][" types" ]. find({ type -> (type[" name" ] == " Query" ) })
102- queryType[" appliedDirectives" ] == [[name : " example" , args : [[name : " argName" , value : ' "onQuery"' ]]]]
97+ queryType[" appliedDirectives" ] == [
98+ [name : " example" , args : [[name : " argName" , value : ' "onQuery"' ]]],
99+ [name : " noDefault" , args : [[name : " arg1" , value : ' "set"' ]]]
100+ ]
103101
104102 def helloType = er. data[" __schema" ][" types" ]. find({ type -> (type[" name" ] == " Hello" ) })
105- helloType[" appliedDirectives" ] == [[name : " example" , args : [[name : " argName" , value : ' "default"' ]]]]
103+ helloType[" appliedDirectives" ] == [
104+ [name : " example" , args : [[name : " argName" , value : ' "default"' ]]],
105+ [name : " noDefault" , args : []] // always empty list
106+ ]
106107
107108 def worldField = helloType[" fields" ]. find({ type -> (type[" name" ] == " world" ) })
108109 worldField[" appliedDirectives" ] == [[name : ' deprecated' , args : [[name : ' reason' , value : ' "No longer supported"' ]]]]
0 commit comments