-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Unable to determine the channel name dynamically in a subscription resolver #1385
Comments
After a couple of days of debugging this, I came up with this solution. My GraphQL schema: As you can see, we can pass arguments to subscribe function: On the frontend GraphQL Query looks like this: Modules: Questions: mihajlo@morpher.io |
Thanks very much for reporting this! We think this is a great idea, and would definitely love a PR for the docs. If you (or anyone else) is interested in working on this, that would be great - thanks! |
Looking at all the examples the subscription resolver is of the form:
messageCreated: { subscribe: () => pubsub.asyncIterator(MESSAGE_CREATED), }
i.e. it returns an object with a subscribe property. However I need to be able to dynamically set the channel based on the set of parameters coming through from the client, when they subscribe. I would like to request that the subscription resolver be generalized to a function that returns the object with the subscribe property. The resolver should then look like:
messageCreated(variables) { return { subscribe: pubsub.asyncIterator(variables.topic), } }
The text was updated successfully, but these errors were encountered: