diff options
Diffstat (limited to 'tests/Language/GraphQL/ValidateSpec.hs')
| -rw-r--r-- | tests/Language/GraphQL/ValidateSpec.hs | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/Language/GraphQL/ValidateSpec.hs b/tests/Language/GraphQL/ValidateSpec.hs index 4063b57..d340d4e 100644 --- a/tests/Language/GraphQL/ValidateSpec.hs +++ b/tests/Language/GraphQL/ValidateSpec.hs @@ -485,7 +485,7 @@ spec = "Variable \"$dog\" cannot be non-input type \"Dog\"." , locations = [AST.Location 2 34] } - in validate queryString `shouldBe` [expected] + in validate queryString `shouldContain` [expected] it "rejects undefined variables" $ let queryString = [r| @@ -808,3 +808,35 @@ spec = , locations = [AST.Location 4 19] } in validate queryString `shouldBe` [expected] + + it "wrongly typed variable arguments" $ + let queryString = [r| + query catCommandArgQuery($catCommandArg: CatCommand) { + cat { + doesKnowCommand(catCommand: $catCommandArg) + } + } + |] + expected = Error + { message = + "Variable \"$catCommandArg\" of type \"CatCommand\" \ + \used in position expecting type \"!CatCommand\"." + , locations = [AST.Location 2 40] + } + in validate queryString `shouldBe` [expected] + + it "wrongly typed variable arguments" $ + let queryString = [r| + query intCannotGoIntoBoolean($intArg: Int) { + dog { + isHousetrained(atOtherHomes: $intArg) + } + } + |] + expected = Error + { message = + "Variable \"$intArg\" of type \"Int\" used in position \ + \expecting type \"Boolean\"." + , locations = [AST.Location 2 44] + } + in validate queryString `shouldBe` [expected] |
