Folks, I'm struggling to have it working, but the ...
# general
Folks, I'm struggling to have it working, but the problem is not really SuperTokens but Apollo Server. I'm trying to use subscriptions, following this guide ( It "works" but I can't put SuperTokens' session in the context. Any suggestion ?
let me answer myself:
For queries and mutations, I can access the session with this
For Subscriptions: there are no headers/cookies for
so it can't
I just realised I don't really need to access the current user on the subscription resolvers. Just luck.
if you really need that, the key is: create a query that returns the user id and on the client use this ID in the URL for the websocket:
hmm. I see. Yea.. websocket auth is totally different. Probably would want to use the session handle instead of the userId
Or a JWT and verify that on each websocket message
That approach would work but Apollo subscriptions using web sockets let you pass an additional
that can be accessed in your subscriptions and then added to the context passed to your resolvers. The Apollo documentation contains a small (albeit slightly confusing) example of this: Not sure if thats more complex than what you came up with for your use case, but looks like thats how its intended to work.