Merge pull request #11635 from backstage/rugvip/graphiql-headers

graphiql: fix headers not being included in requests
This commit is contained in:
Ben Lambert
2022-05-30 11:58:47 +02:00
committed by GitHub
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),
});