Subscriptions with Nested connected data returns [Object Object] #306
Comments
Same issue for me, with the same tutorial. The actual content returned via websocket is: This is for the query:
I think this issue is similar to #236 There is no dataloader as I wanted to make sure that it wasn't the origin of the issue. |
After some more digging it turns out that the problem comes from the empty context passed on subscriptions. SubscriptionServer.create(
{
execute, subscribe, schema,
onOperation: (message, params, webSocket) => {
return { ...params, context: {mongo} }
},
},
{ server, path: '/subscriptions' },
); Note that I am not passing the |
@nharraud, thanks! it works! That took care of it. For reference, in case anyone is making this change in the lesson...
Object.assign(
params,
{
context: {
mongo,
dataloaders: buildDataloaders(mongo)
}
}) |
@MoonTahoe, I think it would be better if you create an issue in And, actually, I did the same thing when I was studying that tutorial too. 👍 Also, this issue can be closed, I believe. |
Yea, thanks. I've seen this happen before so I originally though it may be a transport issue. |
I discovered this issue when reviewing the chapter on subscriptions on the How to GraphQL website.
The sample and example works, but If you try to subscribe to connected data you get [Object object] in Graphiql.
In the lesson, the following Subscription type is created:
And in the Subscription resolver pubsub is setup...
And in the create link Resolver a Link event is published
So far everything works: in fact if I add the subscription to Graphiql it all works...
The Issue...
occurs when I try to request nested link data. In a typical query for allLinks I can connect users through the postedBy resolver. However, in the subscription trying to see the postedBy user info causes the subscription response to break.
Intended Outcome: the connected user's data is returned in the subscription.
Actual Outcome: [Object, object] is returned by graphiql
Subscription that causes the problem:
I noticed that that when a subscription is published the Link resolvers that find the postedBy connection are not invoked:
I've tried adding code to find the user directly to the mutation, but the subscription still returns [Object Object]
When I use pubsub.publish... how can I make nested resolvers work with subscriptions.
The text was updated successfully, but these errors were encountered: