3

I am new to GraphQL and have built a simple API using express and express-graphql. When I run my server and go to http://localhost:5000/graphql in the browser I see GraphiQL and can make basic queries.

I want to set the HTTP headers of a request however. I believe there should be a HTTP Headers tab next to the Query Variables tab in the screenshot below, but for some reason it is not there.

Any ideas why it is missing or how I then set the HTTP headers of a request to my API?

screenshot

Reno
  • 1,039
  • 3
  • 14
  • 22

1 Answers1

1

In graphiql v1, you can set the headerEditorEnabled prop:

<GraphiQL
  ref={graphiql}
  headerEditorEnabled
  fetcher={(attributes) => graphQLFetcher(attributes)}
>

As of v1.9.8, headerEditorEnabled defaults to true

In graphiql v2, headerEditorEnabled has been renamed to isHeadersEditorEnabled.

movermeyer
  • 1,502
  • 2
  • 13
  • 19
  • Kudos, and while this is true, please note that express-graphql is no longer maintained. So I believe if the OP use express-graphql, it will still be using the old `headerEditorEnabled`. https://github.com/graphql/express-graphql/blob/main/package.json#L90 – ksugiarto Jun 22 '23 at 04:12