Validate required input fields

This commit is contained in:
2020-10-04 18:51:21 +02:00
parent d5f518fe82
commit a91bc7f2d2
9 changed files with 128 additions and 48 deletions

View File

@ -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]