From 7f17999486053dbfddbdddd761ac0b262b716ee1 Mon Sep 17 00:00:00 2001 From: Jonathan Gruber Date: Fri, 6 Oct 2023 23:48:40 +0200 Subject: [PATCH] fix(#354): add set headers to introspection request --- .../src/ipc/network/prepare-gql-introspection-request.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/bruno-electron/src/ipc/network/prepare-gql-introspection-request.js b/packages/bruno-electron/src/ipc/network/prepare-gql-introspection-request.js index 8329941f..4a1e41c8 100644 --- a/packages/bruno-electron/src/ipc/network/prepare-gql-introspection-request.js +++ b/packages/bruno-electron/src/ipc/network/prepare-gql-introspection-request.js @@ -16,6 +16,7 @@ const prepareGqlIntrospectionRequest = (endpoint, envVars, request) => { method: 'POST', url: endpoint, headers: { + ...mapHeaders(request.headers), Accept: 'application/json', 'Content-Type': 'application/json' }, @@ -38,4 +39,10 @@ const prepareGqlIntrospectionRequest = (endpoint, envVars, request) => { return axiosRequest; }; +const mapHeaders = (headers) => { + const entries = headers.filter((header) => header.enabled).map(({ name, value }) => [name, value]); + + return Object.fromEntries(entries); +}; + module.exports = prepareGqlIntrospectionRequest;