Closed danielberkompas closed 8 years ago
Take a look at this PR for my attempt at solving this. https://github.com/joshprice/plug_graphql/pull/9
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.
Closed by #9
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:
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:https://github.com/joshprice/plug_graphql/blob/21e42b00cdd9d689f5f048859e66f253d1c8d3e7/lib/graphql/plug/endpoint.ex#L44
The core GraphQL Elixir library may need to be extended to pass the context to all the resolvers.
Am I missing something here?