summaryrefslogtreecommitdiff
path: root/tests/Language
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2020-11-06 08:33:51 +0100
committerEugen Wissner <belka@caraus.de>2020-11-06 08:33:51 +0100
commit4a3b4cb16d7da9c356b514ab48bdc0e527acd377 (patch)
tree4a395ea99597973e55388163f69545adadb860c2 /tests/Language
parent7f0fb187169938f7b9b2333b5cc79293813c0eb1 (diff)
downloadgraphql-4a3b4cb16d7da9c356b514ab48bdc0e527acd377.tar.gz
Fix singleFieldSubscriptionsRule fragment lookup
singleFieldSubscriptionsRule picks up a wrong fragment definition.
Diffstat (limited to 'tests/Language')
-rw-r--r--tests/Language/GraphQL/ValidateSpec.hs36
1 files changed, 34 insertions, 2 deletions
diff --git a/tests/Language/GraphQL/ValidateSpec.hs b/tests/Language/GraphQL/ValidateSpec.hs
index 3bfa018..318045c 100644
--- a/tests/Language/GraphQL/ValidateSpec.hs
+++ b/tests/Language/GraphQL/ValidateSpec.hs
@@ -92,6 +92,7 @@ petType = InterfaceType "Pet" Nothing []
subscriptionType :: ObjectType IO
subscriptionType = ObjectType "Subscription" Nothing [] $ HashMap.fromList
[ ("newMessage", newMessageResolver)
+ , ("disallowedSecondRootField", newMessageResolver)
]
where
newMessageField = Field Nothing (Out.NonNullObjectType messageType) mempty
@@ -165,7 +166,8 @@ spec =
|]
expected = Error
{ message =
- "Subscription sub must select only one top level field."
+ "Subscription \"sub\" must select only one top level \
+ \field."
, locations = [AST.Location 2 15]
}
in validate queryString `shouldContain` [expected]
@@ -186,7 +188,8 @@ spec =
|]
expected = Error
{ message =
- "Subscription sub must select only one top level field."
+ "Subscription \"sub\" must select only one top level \
+ \field."
, locations = [AST.Location 2 15]
}
in validate queryString `shouldContain` [expected]
@@ -631,3 +634,32 @@ spec =
, locations = [AST.Location 3 34]
}
in validate queryString `shouldBe` [expected]
+
+ it "finds corresponding subscription fragment" $
+ let queryString = [r|
+ subscription sub {
+ ...anotherSubscription
+ ...multipleSubscriptions
+ }
+ fragment multipleSubscriptions on Subscription {
+ newMessage {
+ body
+ }
+ disallowedSecondRootField {
+ sender
+ }
+ }
+ fragment anotherSubscription on Subscription {
+ newMessage {
+ body
+ sender
+ }
+ }
+ |]
+ expected = Error
+ { message =
+ "Subscription \"sub\" must select only one top level \
+ \field."
+ , locations = [AST.Location 2 15]
+ }
+ in validate queryString `shouldBe` [expected]