How to auto-generate or persist HTTP Headers between Redwood GraphQL Playground restarts?

I’m able to authenticate with Redwood GraphQL Playground by passing {"auth-provider": "<provider>", "authorization": "Bearer <token>"} as HTTP Headers, but I have to copy/paste these headers every time I restart the Playground. Does anyone know of a good way to persist these headers between restarts of the playground?

I can think of 3 possible approaches:

  1. (Ideal) If I’m already logged into the app, then automatically generate these two HTTP Headers, based upon the data in Local Storage for the currentUser
  2. Generate the HTTP Headers based upon an environment variable or a config file
  3. Simply persist the HTTP Headers between restarts (I believe GraphiQL does this)

Hi @mattsears18 I have written up an RFC for a way to implement a function that can (in dev) generate valid headers and mock a user for the GraphQL playground here: RFC: Improve GraphQL DX by setting authentication headers in GraphiQL · Issue #5007 · redwoodjs/redwood · GitHub

Thought comments and PR’s welcome!

1 Like

Thanks! I’ll take a look.