diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/Language/GraphQL/ValidateSpec.hs | 37 |
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] |
