Proposal: Default headers for GraphQLPlayground.init
See original GitHub issueI’m building a Ruby on Rails integration for GraphQL Playground - here.
In a lot of Ruby on Rails application, developers use the GraphQL
with the build in CSRF protection.
For the gem to work, I have to be able to set default headers for the GraphQL endpoint. I imagining the following would do the trick:
window.addEventListener('load', function (event) {
GraphQLPlayground.init(document.getElementById('root'), {
endpoint: '<%= graphql_endpoint_path %>',
headers: {
'X-CSRF-Token': '<%= form_authenticity_token %>',
},
});
});
This would also be useful, for default authentication headers and similar.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:10
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Proposal: Default headers for GraphQLPlayground.init #636
I'm building a Ruby on Rails integration for GraphQL Playground - here. ... Proposal: Default headers for GraphQLPlayground.init #636.
Read more >Setting Up Authentication and Authorization with Apollo ...
If we try running the viewer query from GraphQL Playground without an Authorization header, then we'll see an error of Not Authorised! now...
Read more >Spring for GraphQL Documentation
A GraphQL Java application can register a DataFetcherExceptionHandler to decide how to represent exceptions from the data layer in the "errors" ...
Read more >Using the GraphQL Playground - WellLine
After the headers area is configured, the "error": "Unexpected token < in JSON at position 0" message will be removed, indicating the playground...
Read more >GraphQL - Strapi Developer Docs
The GraphQL Playground is enabled by default for both the development and staging environments, but disabled in production environments.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Seconding this – I was working on a PR to add
graphql-playground
as an optional interface to graphene-django, but the inability to set headers through the playground’sinit
function makes this impossible.The
<Playground />
component acceptsheaders
as an optional prop. I’m pretty sure the prop would simply have to be added to<PlaygroundWrapper />
and<GraphQLBinApp />
.I lack React expertise, but if someone can confirm my thoughts on passing this prop down, I’d be happy to make a PR.
Thanks to @wilsongp its done in #825 and will be released in the new version of the playground.