1package graphql_test 2 3import ( 4 "testing" 5 6 "github.com/graphql-go/graphql" 7 "github.com/graphql-go/graphql/gqlerrors" 8 "github.com/graphql-go/graphql/testutil" 9) 10 11func TestValidate_VariablesAreInputTypes_(t *testing.T) { 12 testutil.ExpectPassesRule(t, graphql.VariablesAreInputTypesRule, ` 13 query Foo($a: String, $b: [Boolean!]!, $c: ComplexInput) { 14 field(a: $a, b: $b, c: $c) 15 } 16 `) 17} 18func TestValidate_VariablesAreInputTypes_1(t *testing.T) { 19 testutil.ExpectFailsRule(t, graphql.VariablesAreInputTypesRule, ` 20 query Foo($a: Dog, $b: [[CatOrDog!]]!, $c: Pet) { 21 field(a: $a, b: $b, c: $c) 22 } 23 `, []gqlerrors.FormattedError{ 24 testutil.RuleError(`Variable "$a" cannot be non-input type "Dog".`, 2, 21), 25 testutil.RuleError(`Variable "$b" cannot be non-input type "[[CatOrDog!]]!".`, 2, 30), 26 testutil.RuleError(`Variable "$c" cannot be non-input type "Pet".`, 2, 50), 27 }) 28} 29