-
-
Notifications
You must be signed in to change notification settings - Fork 91
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
Subscriptions based on the userId from authorizer #71
Comments
@tkohout Sorry for late response. Basically if you want to store something in context, you should use See: |
Please, let me know if my advice helped you. |
Thanks @michalkvasnicak,
and then access it from resolver directly on context:
One gotcha would be that if you want to pass around pubSub using context (as per docs) you have to return it for the dynamodb stream as well:
Perhaps authorization could be part of the example? It's a bit hard to setup and I think most of the time the websocket will need to be protected. |
@tkohout thank you very much for this valuable info. An example is really good idea, would you have some free time to prepare some really simple solution in a PR? Also about
Yeah this one maybe should be a part of example too. |
@michalkvasnicak @tkohout thanks for this info it's really helpful and would be nice to add this to the readme or the code example |
@michalkvasnicak @tkohout can you guys please explain the benefits of passing the |
@IslamWahid for me GraphQL context can serve as a Dependency injection container that contains all the services, etc. So instead of importing the pubSub or other services that you need, you can expose them in a context and access them anywhere. |
@michalkvasnicak I'm thinking about it performance-wise as it gives me more flexibility to just import it whenever and wherever I need to publish an event instead of injecting it, but just wanted to ask if you're doing this for performance reasons. |
@IslamWahid for me it's just about convenience. It's easier to change type declaration for context and add/remove few things than add/remove multiple import statements from N files. |
Hello,
thanks for this library! I've been trying to setup simple subscriptions based on your example server app.
I managed to setup the authorizer on websocket, and retrieve user in the context function. With something like this:
And the subscription would be something like this:
I assume the
subscribe
function is called from the dynamodb event stream so I am not getting requestContext and the userId with it. How to get it inside of the subscribe function?I came upon this issue: #70 which might be what I am looking for, but I am confused how this would go all together.
Could you point me in the right direction?
Thanks
Tomas
The text was updated successfully, but these errors were encountered: