Passing subscription queries to sources does not work
I'm trying to use mesh as a gateway, and I want the graphql-subscriptions to work as well as queries. There is a repo with my problem representation: https://github.com/germankrause/mesh-issue.
I'm getting an error: Cannot read property 'eventtest' of undefined in graphql-tools: generateProxyingResolvers function. It's trying to resolve payload[targetFieldName], but payload is undefined. I found out that payload is passed rootValue, so I've added it, and now I'm just getting null in the response data. Original source resolver is not even called
I've debugged it and have seen that mesh successfully build the schema using stitching algorithm, but in generateProxyingResolvers it builds non-working resolvers, so I get errors after the mesh bootstrapped when I try to run the subscription query.
@germankrause In source.js, it uses ApolloServer which uses deprecated subscriptions-transport-ws package;
See package.json; https://github.com/apollographql/apollo-server/blob/main/packages/apollo-server-core/package.json#L51
See the deprecation note: https://github.com/apollographql/subscriptions-transport-ws/#graphql-ws
Since Mesh uses the new graphql-ws protocol, you need to upgrade to graphql-ws manually. See https://github.com/enisdenjo/graphql-ws#recipes
And in your gateway.js, you are using express-graphql only which doesn't support subscriptions by itself. And you need to configure it in the same way.
@ardatan I've used graphql-ws on the gateway side, but nothing of the recipes work for my source, the best I've got there is Could not connect to websocket endpoint ws://localhost:3002/graphql (check source-with-graphql-ws.js in the repo). But still, with graphql-ws on the gateway, I get the same error Cannot read property 'eventtest' of undefined from the mesh. And it doesn't even send any request to the source, so it looks like the source implementation doesn't matter here, as schema to stitch stays the same.
@germankrause I'm facing a similar problem, did you manage to make it work?