Fix singleFieldSubscriptionsRule fragment lookup
singleFieldSubscriptionsRule picks up a wrong fragment definition.
This commit is contained in:
@ -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]
|
||||
|
Reference in New Issue
Block a user