diff options
Diffstat (limited to 'tests/Language/GraphQL/ValidateSpec.hs')
| -rw-r--r-- | tests/Language/GraphQL/ValidateSpec.hs | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/tests/Language/GraphQL/ValidateSpec.hs b/tests/Language/GraphQL/ValidateSpec.hs index d340d4e..24b0ad0 100644 --- a/tests/Language/GraphQL/ValidateSpec.hs +++ b/tests/Language/GraphQL/ValidateSpec.hs @@ -809,7 +809,7 @@ spec = } in validate queryString `shouldBe` [expected] - it "wrongly typed variable arguments" $ + it "rejects wrongly typed variable arguments" $ let queryString = [r| query catCommandArgQuery($catCommandArg: CatCommand) { cat { @@ -825,7 +825,7 @@ spec = } in validate queryString `shouldBe` [expected] - it "wrongly typed variable arguments" $ + it "rejects wrongly typed variable arguments" $ let queryString = [r| query intCannotGoIntoBoolean($intArg: Int) { dog { @@ -840,3 +840,35 @@ spec = , locations = [AST.Location 2 44] } in validate queryString `shouldBe` [expected] + + it "rejects values of incorrect types" $ + let queryString = [r| + { + dog { + isHousetrained(atOtherHomes: 3) + } + } + |] + expected = Error + { message = + "Value ConstInt 3 cannot be coerced to type \"Boolean\"." + , locations = [AST.Location 4 48] + } + in validate queryString `shouldBe` [expected] + + it "checks for (non-)nullable arguments" $ + let queryString = [r| + { + dog { + doesKnowCommand(dogCommand: null) + } + } + |] + expected = Error + { message = + "Field \"doesKnowCommand\" argument \"dogCommand\" of \ + \type \"DogCommand\" is required, but it was not \ + \provided." + , locations = [AST.Location 4 19] + } + in validate queryString `shouldBe` [expected] |
