diff --git a/.changeset/sixty-poems-drum.md b/.changeset/sixty-poems-drum.md new file mode 100644 index 0000000000..82c5f6c499 --- /dev/null +++ b/.changeset/sixty-poems-drum.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-graphiql': patch +--- + +Fix for custom headers not being included in requests. diff --git a/plugins/graphiql/src/lib/api/GraphQLEndpoints.ts b/plugins/graphiql/src/lib/api/GraphQLEndpoints.ts index 7287eb579b..7f9c0ca4ee 100644 --- a/plugins/graphiql/src/lib/api/GraphQLEndpoints.ts +++ b/plugins/graphiql/src/lib/api/GraphQLEndpoints.ts @@ -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 => { @@ -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), });