Does anyone know a way to `getUserId(ctx)` from a ...
# orm-help
w
Does anyone know a way to
getUserId(ctx)
from a subscription ? It looks like
ctx.request
is null from a subscription 😞
Looks like it’s hidden here
ctx.connection.context['Authorization'];
πŸ‘ 1
n
that's because it's a connection and not separate HTTP requests
lacking the correct terminology here, I'm sure πŸ™‚
w
Yeah, ended up finding why! Although I never found how to setup a middleware to set the subscription
connectionParams
. I even found an issue that you posted asking for it, but the solutions weren't working 😞
I tried to take the playground as example (cause it's working with it), but the way it's handled seems quite specific
n
There were some longer discussions about that in the s-t-ws repo, maybe you can search more πŸ™‚ Alternatively, simply create a new connection from the client with the new params
w
I think the latter is the way you handled it in the playground ! I scrapped the whole repo/google/stackoverflow looking for it. https://github.com/apollographql/subscriptions-transport-ws/issues/113#issuecomment-388524528 This should be working, the middleware is properly called but the
context
server side remains empty 😞
n
hmm might be worth to provide a minimal reproduction to that repo πŸ™‚
w
Alright ! Thanks for your help πŸ™