UNPKG

@graphql-mesh/plugin-serialize-headers

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