Skip to content

Support customer headers in graphiql editor #369

@lpil

Description

@lpil

Often we want our graphql endpoints to be behind header based authentication so that we can protect private data and identify the user. This becomes a problem when we wish to use the graphiql for development/testing/documentation because there is no way of setting the required authentication header.

I would like to be able to supply additional headers for graphiql to use when making requests to the graphql endpoint.

I was thinking that perhaps we could add a juniper::graphiql::graphiql_source_with_config or similar that takes the endpoint (as before) and a struct of options which (for now) has one field request_headers: Vec<(String, String)>.

These headers would then be added to the headers used in the graphiql fetcher

headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},

Each of the web frameworks would then need to be updated to expose a handler for this new graphiql function for developers to use.

I would be happy to contribute this change if it is likely to be merged.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementImprovement of existing features or bugfix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions