From 2dcefff76ad4b889a386f3431baa9ee2b4c80568 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sun, 10 Nov 2024 22:23:54 +0100 Subject: [PATCH] Add test for introspection as subscription root Add a pending test checking that an introspection field cannot be subscription root. --- tests/Language/GraphQL/Validate/RulesSpec.hs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/Language/GraphQL/Validate/RulesSpec.hs b/tests/Language/GraphQL/Validate/RulesSpec.hs index 02f2cde..af3b38e 100644 --- a/tests/Language/GraphQL/Validate/RulesSpec.hs +++ b/tests/Language/GraphQL/Validate/RulesSpec.hs @@ -18,7 +18,7 @@ import qualified Language.GraphQL.AST.DirectiveLocation as DirectiveLocation import qualified Language.GraphQL.Type.In as In import qualified Language.GraphQL.Type.Out as Out import Language.GraphQL.Validate -import Test.Hspec (Spec, context, describe, it, shouldBe, shouldContain) +import Test.Hspec (Spec, context, describe, it, shouldBe, shouldContain, xit) import Text.Megaparsec (parse, errorBundlePretty) petSchema :: Schema IO @@ -206,6 +206,18 @@ spec = } in validate queryString `shouldContain` [expected] + xit "rejects an introspection field as the subscription root" $ + let queryString = "subscription sub {\n\ + \ __typename\n\ + \}" + expected = Error + { message = + "Subscription \"sub\" must select only one top \ + \level field." + , locations = [AST.Location 1 1] + } + in validate queryString `shouldContain` [expected] + it "rejects multiple subscription root fields coming from a fragment" $ let queryString = "subscription sub {\n\ \ ...multipleSubscriptions\n\