Use conn as context for query execution
danielberkompas opened this issue · 3 comments
It's very important to know who the current user is when you resolve queries. It's pretty easy to assign this information to the conn using plugs before the GraphQL plug, like so:
plug :authenticate_user
plug GraphQL.Endpoint, ...However, since the conn is not passed into the query execution function, the resolvers have no way to know who the current user is, and therefore authentication seems impossible.
I think the conn should be added as the third argument to this function:
The core GraphQL Elixir library may need to be extended to pass the context to all the resolvers.
Am I missing something here?
GraphQL definitely can't know about conn but root_value should allow custom data to be passed in from the plug.
This is such a common use case it'd be great to have an example illustrating how to set this up.