Enable GraphiQL header editor

This commit enables a new tab in the GraphiQL UI that allows editing
request headers.

Closes gh-142
This commit is contained in:
Koen Punt
2021-09-21 11:41:36 +02:00
committed by Brian Clozel
parent 93c696f9bc
commit d550d384d8

View File

@@ -61,11 +61,12 @@
></script>
<script>
function graphQLFetcher(path) {
return graphQLParams => fetch(
return (graphQLParams, options = {}) => fetch(
`${location.protocol}//${location.host}${path}`,
{
method: 'post',
headers: {
...options.headers,
Accept: 'application/json',
'Content-Type': 'application/json',
},
@@ -86,6 +87,7 @@
React.createElement(GraphiQL, {
fetcher: gqlFetcher,
defaultVariableEditorOpen: true,
headerEditorEnabled: true
}),
document.getElementById('graphiql'),
);