MCPcopy Create free account
hub / github.com/dailydotdev/apps / getClientHeaders

Function getClientHeaders

packages/shared/src/graphql/batch.ts:59–88  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

57// Mirrors how the `unsetHeader` patch in `common.ts` reaches the client's own
58// headers, so a batch carries the same auth/client headers a single request has.
59const getClientHeaders = (): Record<string, string> => {
60 const options = Reflect.get(gqlClient, 'options');
61 const headers =
62 options && typeof options === 'object'
63 ? Reflect.get(options, 'headers')
64 : undefined;
65
66 if (!headers) {
67 return {};
68 }
69
70 if (typeof Headers !== 'undefined' && headers instanceof Headers) {
71 const plain: Record<string, string> = {};
72 headers.forEach((value, key) => {
73 plain[key] = value;
74 });
75
76 return plain;
77 }
78
79 if (Array.isArray(headers)) {
80 return Object.fromEntries(headers as Array<[string, string]>);
81 }
82
83 if (typeof headers === 'object') {
84 return { ...(headers as Record<string, string>) };
85 }
86
87 return {};
88};
89
90const operationNamePattern = /(?:query|mutation|subscription)\s+(\w+)/;
91

Callers 1

flushFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected