@graphql-mesh/plugin-serialize-headers
Version:
24 lines (23 loc) • 714 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) {
var _a;
const headersObj = {};
for (const [key, value] of headers) {
const finalKey = (_a = map[key]) !== null && _a !== void 0 ? _a : key;
headersObj[finalKey] = value;
}
return headersObj;
}
return {
onFetch({ options }) {
options.headersSerializer = headersSerializer;
},
};
}
exports.default = useMeshSerializeHeaders;