| 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. |
| 59 | const 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 | |
| 90 | const operationNamePattern = /(?:query|mutation|subscription)\s+(\w+)/; |
| 91 | |