summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2020-12-26 06:31:56 +0100
committerEugen Wissner <belka@caraus.de>2020-12-26 06:31:56 +0100
commit22abf7ca58091a521de037bd9b22689e7309b8ba (patch)
tree051ddbce9291d65f29dcae3b4da4255ef019bd91 /tests
parent5a6709030ceee63adb417c0fa2d2abce24c5d5cb (diff)
downloadgraphql-22abf7ca58091a521de037bd9b22689e7309b8ba.tar.gz
Validate variable usages are allowed in arguments
Diffstat (limited to 'tests')
-rw-r--r--tests/Language/GraphQL/ValidateSpec.hs34
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]