fix(#354): add set headers to introspection request

This commit is contained in:
Jonathan Gruber 2023-10-06 23:48:40 +02:00
parent d2b35beb6f
commit 7f17999486

View File

@ -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;