From 21a7d9cce421352e837945a2334e7ccf10160d8c Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sat, 19 Sep 2020 18:18:26 +0200 Subject: Validate variable names are unique --- tests/Language/GraphQL/ValidateSpec.hs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/Language/GraphQL/ValidateSpec.hs b/tests/Language/GraphQL/ValidateSpec.hs index 507ca7b..1822f57 100644 --- a/tests/Language/GraphQL/ValidateSpec.hs +++ b/tests/Language/GraphQL/ValidateSpec.hs @@ -441,3 +441,18 @@ spec = , locations = [AST.Location 3 23, AST.Location 3 39] } in validate queryString `shouldBe` Seq.singleton expected + + it "rejects duplicate variables" $ + let queryString = [r| + query houseTrainedQuery($atOtherHomes: Boolean, $atOtherHomes: Boolean) { + dog { + isHousetrained(atOtherHomes: $atOtherHomes) + } + } + |] + expected = Error + { message = + "There can be only one variable named \"atOtherHomes\"." + , locations = [AST.Location 2 39, AST.Location 2 63] + } + in validate queryString `shouldBe` Seq.singleton expected -- cgit v1.2.3