Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing subscription queries to sources does not work #1472

Open
germankrause opened this issue Jan 25, 2021 · 3 comments
Open

Passing subscription queries to sources does not work #1472

germankrause opened this issue Jan 25, 2021 · 3 comments

Comments

@germankrause
Copy link
Contributor

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.

@ardatan
Copy link
Owner

ardatan commented Jan 25, 2021

@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.

@germankrause
Copy link
Contributor Author

@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.

@kantum
Copy link

kantum commented May 23, 2023

@germankrause I'm facing a similar problem, did you manage to make it work?

@theguild-bot theguild-bot mentioned this issue Sep 28, 2023
This was referenced Apr 30, 2024
This was referenced May 7, 2024
klippx pushed a commit to klippx/graphql-mesh that referenced this issue Oct 9, 2024
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants