@graphql-mesh/plugin-serialize-headers
Version:
23 lines (22 loc) • 661 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
function useMeshSerializeHeaders(options) {
const map = {};
for (const headerName of options.names) {
map[headerName.toLowerCase()] = headerName;
}
function headersSerializer(headers) {
const headersObj = {};
for (const [key, value] of headers) {
const finalKey = map[key] ?? key;
headersObj[finalKey] = value;
}
return headersObj;
}
return {
onFetch({ options }) {
options.headersSerializer = headersSerializer;
},
};
}
exports.default = useMeshSerializeHeaders;