From e6a6926e18a032a129936794184b518189207648 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Wed, 26 Aug 2020 18:58:48 +0200 Subject: Validate anonymous operation definitions --- tests/Language/GraphQL/ValidateSpec.hs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests/Language') diff --git a/tests/Language/GraphQL/ValidateSpec.hs b/tests/Language/GraphQL/ValidateSpec.hs index c463dd9..4b5e638 100644 --- a/tests/Language/GraphQL/ValidateSpec.hs +++ b/tests/Language/GraphQL/ValidateSpec.hs @@ -209,3 +209,27 @@ spec = , path = [] } in validate queryString `shouldBe` Seq.singleton expected + + it "rejects multiple anonymous operations" $ + let queryString = [r| + { + dog { + name + } + } + + query getName { + dog { + owner { + name + } + } + } + |] + expected = Error + { message = + "This anonymous operation must be the only defined operation." + , locations = [AST.Location 2 15] + , path = [] + } + in validate queryString `shouldBe` Seq.singleton expected -- cgit v1.2.3