summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2020-09-26 09:06:30 +0200
committerEugen Wissner <belka@caraus.de>2020-09-26 09:06:30 +0200
commitced9b815db516ac4196856c535eedca85f4a1935 (patch)
treea5bd00dc7fd6d839f31137b5de2447de19039ce0 /tests
parent3373c94895c148ffec199842305e10528440e5bd (diff)
downloadgraphql-ced9b815db516ac4196856c535eedca85f4a1935.tar.gz
Validate leaf selections
Diffstat (limited to 'tests')
-rw-r--r--tests/Language/GraphQL/ValidateSpec.hs37
1 files changed, 36 insertions, 1 deletions
diff --git a/tests/Language/GraphQL/ValidateSpec.hs b/tests/Language/GraphQL/ValidateSpec.hs
index 9127a94..1649ad1 100644
--- a/tests/Language/GraphQL/ValidateSpec.hs
+++ b/tests/Language/GraphQL/ValidateSpec.hs
@@ -500,7 +500,9 @@ spec =
it "rejects duplicate fields in input objects" $
let queryString = [r|
{
- findDog(complex: { name: "Fido", name: "Jack" })
+ findDog(complex: { name: "Fido", name: "Jack" }) {
+ name
+ }
}
|]
expected = Error
@@ -509,3 +511,36 @@ spec =
, locations = [AST.Location 3 36, AST.Location 3 50]
}
in validate queryString `shouldBe` [expected]
+
+ it "rejects undefined fields" $
+ let queryString = [r|
+ {
+ dog {
+ meowVolume
+ }
+ }
+ |]
+ expected = Error
+ { message =
+ "Cannot query field \"meowVolume\" on type \"Dog\"."
+ , locations = [AST.Location 4 19]
+ }
+ in validate queryString `shouldBe` [expected]
+
+ it "rejects scalar fields with not empty selection set" $
+ let queryString = [r|
+ {
+ dog {
+ barkVolume {
+ sinceWhen
+ }
+ }
+ }
+ |]
+ expected = Error
+ { message =
+ "Field \"barkVolume\" must not have a selection since \
+ \type \"Int\" has no subfields."
+ , locations = [AST.Location 4 19]
+ }
+ in validate queryString `shouldBe` [expected]