File tree Expand file tree Collapse file tree
src/test/groovy/graphql/schema/idl Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1039,7 +1039,7 @@ class SchemaGeneratorTest extends Specification {
10391039 def " scalar default value is parsed" () {
10401040 def spec = """
10411041 type Query {
1042- field(arg1 : Int! = 10, arg2 : [Int!]! = [20], argNoDefault : Int ) : String
1042+ field(arg1 : Int! = 10, arg2 : [Int!]! = [20]) : String
10431043 }
10441044 """
10451045
@@ -1048,12 +1048,26 @@ class SchemaGeneratorTest extends Specification {
10481048 GraphQLObjectType query = schema. getType(" Query" ) as GraphQLObjectType
10491049 Object arg1 = query. getFieldDefinition(" field" ). getArgument(" arg1" ). defaultValue
10501050 Object arg2 = query. getFieldDefinition(" field" ). getArgument(" arg2" ). defaultValue
1051- Object argNoDefault = query. getFieldDefinition(" field" ). getArgument(" argNoDefault" ). defaultValue
10521051
10531052 expect :
10541053 arg1 instanceof Integer
10551054 arg2 instanceof List
10561055 (arg2 as List ). get(0 ) instanceof Integer
1056+ }
1057+
1058+ def " null default arguments are ok" () {
1059+ def spec = """
1060+ type Query {
1061+ field(argNoDefault : Int) : String
1062+ }
1063+ """
1064+
1065+ def schema = schema(spec)
1066+ schema. getType(" Query" ) instanceof GraphQLObjectType
1067+ GraphQLObjectType query = schema. getType(" Query" ) as GraphQLObjectType
1068+ Object argNoDefault = query. getFieldDefinition(" field" ). getArgument(" argNoDefault" ). defaultValue
1069+
1070+ expect :
10571071 argNoDefault == null
10581072 }
10591073
You can’t perform that action at this time.
0 commit comments