summaryrefslogtreecommitdiff
path: root/tests/Language
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2020-10-04 18:51:21 +0200
committerEugen Wissner <belka@caraus.de>2020-10-05 14:51:21 +0200
commita91bc7f2d218ea2df308d3968587b60351625150 (patch)
tree3c3170437b0c903e2c63540c028c1aaa4ff35c17 /tests/Language
parentd5f518fe827d3d279d6c37740820f296689539e4 (diff)
downloadgraphql-a91bc7f2d218ea2df308d3968587b60351625150.tar.gz
Validate required input fields
Diffstat (limited to 'tests/Language')
-rw-r--r--tests/Language/GraphQL/ValidateSpec.hs18
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/Language/GraphQL/ValidateSpec.hs b/tests/Language/GraphQL/ValidateSpec.hs
index 60e717a..92b3001 100644
--- a/tests/Language/GraphQL/ValidateSpec.hs
+++ b/tests/Language/GraphQL/ValidateSpec.hs
@@ -594,7 +594,7 @@ spec =
it "rejects undefined input object fields" $
let queryString = [r|
{
- findDog(complex: { favoriteCookieFlavor: "Bacon" }) {
+ findDog(complex: { favoriteCookieFlavor: "Bacon", name: "Jack" }) {
name
}
}
@@ -620,3 +620,19 @@ spec =
, locations = [AST.Location 2 21]
}
in validate queryString `shouldBe` [expected]
+
+ it "rejects missing required input fields" $
+ let queryString = [r|
+ {
+ findDog(complex: { name: null }) {
+ name
+ }
+ }
+ |]
+ expected = Error
+ { message =
+ "Input field \"name\" of type \"DogData\" is required, \
+ \but it was not provided."
+ , locations = [AST.Location 3 34]
+ }
+ in validate queryString `shouldBe` [expected]