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

Custom context is not passed to subscription creation #1326

Open
HalmiRobi opened this issue Apr 26, 2023 · 1 comment
Open

Custom context is not passed to subscription creation #1326

HalmiRobi opened this issue Apr 26, 2023 · 1 comment

Comments

@HalmiRobi
Copy link

Hi,

I use the custom context function that I pass in the sofa constructor (useSofa(...)), to extract the auth token and pack it into a context, so my GraphQL logic finds it. I can do this for every operation, but not for opening a subscription. When I try to subscribe from a client, I get back an unauthorized error, because of course, the context does not contain my token.
I've checked the router.ts, and there, the contextFactory is not used to create a contextValue, just purely the sofaContext is passed to the subscriptionManager.start. This is done correctly for the subscription update, and when I changed the behavior accordingly to the subscription start, my issue was fixed, the auth token could be extracted.
I would gladly create a pull request, just wanted to ask first, if this is somehow intentional, or really a bug.
Another question would be: can you propose a simple workaround that I can do on my side without having to modify the sofa code?

Thanks,
Robert

@ernestognw
Copy link

ernestognw commented Apr 14, 2024

Same here. Big ➕

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

2 participants