UNPKG

@graphql-mesh/plugin-serialize-headers

Version:
21 lines (20 loc) 609 B
export default 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; }, }; }