drupal-graphql / drupal-graphql/graphql

Integrate graphiql's support of headers in the explorer

Open
#1,392 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
287
Forks
198
PR merge metrics
No merged PRs in 30d

Description

It appears that within [Drupal.behaviors.graphQLRenderExplorer here](https://github.com/drupal-graphql/graphql/blob/8.x-4.x/assets/explorer/src/index.js#L22C1-L30C42), the fetch request does not use the graphiql supported explorer headers.

It looks like the fetch assigns its own headers.

```
// Defines a GraphQL fetcher using the fetch API.
const graphQLFetcher = graphQLParams => fetch(settings.graphqlRequestUrl, {
method: 'post',
credentials: 'same-origin',
body: JSON.stringify(graphQLParams),
headers: {
'Content-Type': 'application/json',
},
}).then(response => response.json());
```

graphiql supports sending custom request headers through its UI as seen in the screen shot below.
![image](https://github.com/drupal-graphql/graphql/assets/4835629/34445436-38e1-41b7-b986-079e041eece8)

Am I looking at this correctly?

It would be sweet to send custom request headers, e.g. Authorization bearer tokens with the request.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.