Skip to content

Commit

Permalink
fix(graphiql): request headers not submitted with the request
Browse files Browse the repository at this point in the history
Although the headers editor was present (graphql-java-kickstart#441), it was non-functional
because only the preconfigured headers were submitted, regardless of the
content of the request headers tab.
  • Loading branch information
BlasiusSecundus committed Nov 25, 2020
1 parent 4eab2c8 commit efb6ec2
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@

var headers = ${headers}

function onEditHeaders(newHeaders) {
try {
headers = JSON.parse(newHeaders)
console.log("Headers successfully updated.")
} catch(e) {
console.warn("The content of the request headers tab is not a valid json: " + e.message)
headers = {}
}
}

// Defines a GraphQL fetcher using the fetch API. You're not required to
// use fetch, and could instead implement graphQLFetcher however you like,
// as long as it returns a Promise or Observable.
Expand Down Expand Up @@ -153,6 +163,7 @@
props.onEditQuery = onEditQuery
props.onEditVariables = onEditVariables
props.onEditOperationName = onEditOperationName
props.onEditHeaders = onEditHeaders

console.debug(props)
// Render <GraphiQL /> into the body.
Expand Down

0 comments on commit efb6ec2

Please sign in to comment.