diff options
| author | Eugen Wissner <belka@caraus.de> | 2020-10-04 18:51:21 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2020-10-05 14:51:21 +0200 |
| commit | a91bc7f2d218ea2df308d3968587b60351625150 (patch) | |
| tree | 3c3170437b0c903e2c63540c028c1aaa4ff35c17 /tests/Language | |
| parent | d5f518fe827d3d279d6c37740820f296689539e4 (diff) | |
| download | graphql-a91bc7f2d218ea2df308d3968587b60351625150.tar.gz | |
Validate required input fields
Diffstat (limited to 'tests/Language')
| -rw-r--r-- | tests/Language/GraphQL/ValidateSpec.hs | 18 |
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] |
