summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2021-02-03 05:42:10 +0100
committerEugen Wissner <belka@caraus.de>2021-02-03 05:47:40 +0100
commita034f2ce4d6603b030e653b4a4a2c46098ce8880 (patch)
tree920d72caa6cede09d58d96f14157e0a4eb610c93 /tests
parentebf4f4d24edd790b477cce62780693ba426d254d (diff)
downloadgraphql-a034f2ce4d6603b030e653b4a4a2c46098ce8880.tar.gz
Validate values
Diffstat (limited to 'tests')
-rw-r--r--tests/Language/GraphQL/ValidateSpec.hs36
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]