@@ -5,10 +5,14 @@ import graphql.language.BooleanValue
55import graphql.language.EnumValue
66import graphql.language.FloatValue
77import graphql.language.IntValue
8+ import graphql.language.ListType
9+ import graphql.language.NonNullType
810import graphql.language.NullValue
911import graphql.language.ObjectField
1012import graphql.language.ObjectValue
1113import graphql.language.StringValue
14+ import graphql.language.Type
15+ import graphql.language.TypeName
1216import graphql.schema.idl.TypeUtil
1317import spock.lang.Specification
1418
@@ -93,26 +97,27 @@ class ValueToVariableValueCompilerTest extends Specification {
9397 actual. value == expectedValue
9498 actual. variableReference. name == expectedVarName
9599 actual. definition. name == expectedVarName
96- TypeUtil . simplePrint(actual. definition. type) == typeName
100+ // compare actual type
101+ def actualType = actual. definition. type
102+ actualType. isEqualTo(expectedType)
103+ if (actualType instanceof NonNullType || actualType instanceof ListType ){
104+ actualType. type. isEqualTo(expectedType. type)
105+ }
106+ TypeUtil . simplePrint(actualType) == typeName
97107
98108 where :
99- value | varCount | typeName | expectedValue | expectedVarName
100- NullValue . newNullValue(). build() | 1 | " ID" | null | " v1"
101- IntValue . of(666 ) | 2 | " Int!" | 666 | " v2"
102- StringValue . of(" str" ) | 3 | " String" | " str" | " v3"
103- BooleanValue . of(true ) | 4 | " Boolean!" | true | " v4"
104- FloatValue . of(999d ) | 5 | " Float" | 999d | " v5"
105- EnumValue . of(" enumValue" ) | 6 | " Foo!" | " enumValue" | " v6"
106- ObjectValue . newObjectValue()
107- .objectField(ObjectField . newObjectField(). name(" a" ). value(IntValue . of(64 )). build())
108- .objectField(ObjectField . newObjectField(). name(" b" ). value(StringValue . of(" 65" )). build())
109- .build() | 7 | " ObjectType" | [a : 64 , b : " 65" ] | " v7"
110- ArrayValue . newArrayValue()
111- .value(IntValue . of(9 ))
112- .value(StringValue . of(" 10" ))
113- .value(EnumValue . of(" enum" ))
114- .build() | 8 | " ArrayType" | [9 , " 10" , " enum" ] | " v8"
115-
109+ value | varCount | typeName | expectedValue | expectedVarName | expectedType
110+ NullValue . newNullValue(). build() | 1 | " ID" | null | " v1" | new TypeName (" ID" )
111+ IntValue . of(666 ) | 2 | " Int!" | 666 | " v2" | new NonNullType (new TypeName (" Int" ))
112+ StringValue . of(" str" ) | 3 | " String" | " str" | " v3" | new TypeName (" String" )
113+ BooleanValue . of(true ) | 4 | " Boolean!" | true | " v4" | new NonNullType (new TypeName (" Boolean" ))
114+ FloatValue . of(999d ) | 5 | " Float" | 999d | " v5" | new TypeName (" Float" )
115+ EnumValue . of(" enumValue" ) | 6 | " Foo!" | " enumValue" | " v6" | new NonNullType (new TypeName (" Foo" ))
116+ [" a" : IntValue . of(64 ),
117+ " b" :IntValue . of(65 ) ] | 7 | " ObjectType" | [a : 64 , b : 65 ] | " v7" | new TypeName (" ObjectType" )
118+ [StringValue . of(" 9" ),
119+ StringValue . of(" 10" ),
120+ StringValue . of(" 11" )] | 8 | " [String]" | [" 9" , " 10" , " 11" ] | " v8" | new ListType ((new TypeName (" String" )))
116121
117122 }
118123}
0 commit comments