From eebad8a27f164088e356e7936afb9a399c70363a Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Thu, 27 Aug 2020 09:04:31 +0200 Subject: Validate operation name uniqueness Fixes #52. --- tests/Language/GraphQL/ValidateSpec.hs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/Language/GraphQL') diff --git a/tests/Language/GraphQL/ValidateSpec.hs b/tests/Language/GraphQL/ValidateSpec.hs index 4b5e638..a547e21 100644 --- a/tests/Language/GraphQL/ValidateSpec.hs +++ b/tests/Language/GraphQL/ValidateSpec.hs @@ -233,3 +233,25 @@ spec = , path = [] } in validate queryString `shouldBe` Seq.singleton expected + + it "rejects operations with the same name" $ + let queryString = [r| + query dogOperation { + dog { + name + } + } + + mutation dogOperation { + mutateDog { + id + } + } + |] + expected = Error + { message = + "There can be only one operation named \"dogOperation\"." + , locations = [AST.Location 2 15, AST.Location 8 15] + , path = [] + } + in validate queryString `shouldBe` Seq.singleton expected -- cgit v1.2.3