graphql-playground
graphql-playground copied to clipboard
Set global variables for HTTP HEADERS
- [x] GraphQL Playground HTML
- [x] apollo-server-express: "^2.16.0",
What OS and OS version are you experiencing the issue(s) on?
Windows Server 2016
What version of graphql-playground(-electron/-middleware) are you experiencing the issue(s) on?
We're using apollo-server-express
version ^2.16.0
which comes with the Playground build in.
What is the expected behavior?
It would be great if it was possible to store say a token string in a global variable that is then available within the "HTTP HEADERS".
Something like this
{
"authorization": "Bearer ${token}"
}
What is the actual behavior?
Currently when we test a query we have to copy/paste a string in the "HTTP HEADERS" pane that contains a valid token. This needs to be done for every open tab page. It would be great to able to use a global variable for the token string that can be reused in different tabs.
Another, maybe better, option would be to have a place to set the "HTTP HEADERS" globally, for all tabs. So no more copy/pasting would be required.
Global HTTP Header example used by all tabs:
{
"authorization": "Bearer xxxMyTokenxxx"
}
A bit related, it would be awesome to store the endpoint itself as a variable, allowing to switch between different environments (local / staging - QA etc.)
This is one of the biggest "issue" I have with the GraphQL Playground at the moment, especially when concurrent apps such as Insomnia provide that 😅
The readme says the request.globalHeaders
option will accomplish this, but the desktop version doesn't appear to be using them to fetch the schema. Is this expected? Should I install a more up-to-date version?
Just add the token without Bearer.
- added by #992
- merged at 3b84784
For some reason, this doesn't make it into the jsdelivr.net build I'm using.
Where is this 1.7.33 version coming from, anyway? @apollographql/graphql-playground-react in NPM leads to this repository, but the last tag/version here is 1.7.27