From 6daae8a5219f62de98b4a65788e436fb1eac8cba Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Fri, 2 Oct 2020 06:31:38 +0200 Subject: Validate directives are in valid locations --- tests/Language/GraphQL/ValidateSpec.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/Language/GraphQL/ValidateSpec.hs b/tests/Language/GraphQL/ValidateSpec.hs index b4433ca..6bf0a04 100644 --- a/tests/Language/GraphQL/ValidateSpec.hs +++ b/tests/Language/GraphQL/ValidateSpec.hs @@ -606,3 +606,17 @@ spec = , locations = [AST.Location 3 36] } in validate queryString `shouldBe` [expected] + + it "rejects directives in invalid locations" $ + let queryString = [r| + query @skip(if: $foo) { + dog { + name + } + } + |] + expected = Error + { message = "Directive \"@skip\" may not be used on QUERY." + , locations = [AST.Location 2 21] + } + in validate queryString `shouldBe` [expected] -- cgit v1.2.3