Urigo/SOFA

Custom context is not passed to subscription creation

HalmiRobi opened this issue · 1 comments

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

Same here. Big ➕