graphiql: fix headers not being included in requests

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-05-20 16:55:24 +02:00
parent 486ebcf3b4
commit 464c33f932
2 changed files with 9 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-graphiql': patch
---
Fix for custom headers not being included in requests.
@@ -59,11 +59,12 @@ export class GraphQLEndpoints implements GraphQLBrowseApi {
return {
id,
title,
fetcher: async (params: any) => {
fetcher: async (params: any, options: any = {}) => {
const body = JSON.stringify(params);
const headers = {
'Content-Type': 'application/json',
...config.headers,
...options.headers,
};
const res = await fetch(url, {
method,
@@ -96,7 +97,7 @@ export class GraphQLEndpoints implements GraphQLBrowseApi {
return {
id,
title,
fetcher: async (params: any) => {
fetcher: async (params: any, options: any = {}) => {
let retried = false;
const doRequest = async (): Promise<any> => {
@@ -105,6 +106,7 @@ export class GraphQLEndpoints implements GraphQLBrowseApi {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${await githubAuthApi.getAccessToken()}`,
...options.headers,
},
body: JSON.stringify(params),
});