Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Use conn as context for query execution #8

@danielberkompas

Description

@danielberkompas

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:

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions