UNPKG

@graphql-mesh/serve-runtime

Version:
25 lines (24 loc) 772 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useForwardHeaders = void 0; function useForwardHeaders(headerNames) { return { onFetch({ options, setOptions, context }) { const forwardedHeaders = {}; for (const headerName of headerNames) { const headerValue = context.headers[headerName]; if (headerValue) { forwardedHeaders[headerName] = headerValue; } } setOptions({ ...options, headers: { ...forwardedHeaders, ...options.headers, }, }); }, }; } exports.useForwardHeaders = useForwardHeaders;