Graphql-playground: Set global variables for HTTP HEADERS

Created on 20 Aug 2020  路  3Comments  路  Source: graphql/graphql-playground

  • [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"
}

image

Most helpful comment

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 馃槄

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gajus picture gajus  路  19Comments

acao picture acao  路  14Comments

grahamb picture grahamb  路  20Comments

schickling picture schickling  路  52Comments

gajus picture gajus  路  20Comments