Skip to content

Commit 3261622

Browse files
committed
Revert "support Headers being passed in fetchOptions"
This reverts commit dc509cc.
1 parent dc509cc commit 3261622

3 files changed

Lines changed: 3 additions & 41 deletions

File tree

.changeset/fluffy-poets-protect.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/core/src/internal/fetchOptions.test.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -107,30 +107,6 @@ describe('makeFetchOptions', () => {
107107
`);
108108
});
109109

110-
it('handles the Headers object', () => {
111-
const headers = new Headers();
112-
headers.append('x-test', 'true');
113-
const operation = makeOperation(queryOperation.kind, queryOperation, {
114-
...queryOperation.context,
115-
fetchOptions: {
116-
headers,
117-
},
118-
});
119-
const body = makeFetchBody(operation);
120-
121-
expect(makeFetchOptions(operation, body)).toMatchInlineSnapshot(`
122-
{
123-
"body": "{\\"operationName\\":\\"getUser\\",\\"query\\":\\"query getUser($name: String) {\\\\n user(name: $name) {\\\\n id\\\\n firstName\\\\n lastName\\\\n }\\\\n}\\",\\"variables\\":{\\"name\\":\\"Clara\\"}}",
124-
"headers": {
125-
"accept": "application/graphql-response+json, application/graphql+json, application/json, text/event-stream, multipart/mixed",
126-
"content-type": "application/json",
127-
"x-test": "true",
128-
},
129-
"method": "POST",
130-
}
131-
`);
132-
});
133-
134110
it('creates a GET request when preferred for query operations', () => {
135111
const operation = makeOperation(queryOperation.kind, queryOperation, {
136112
...queryOperation.context,

packages/core/src/internal/fetchOptions.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,9 @@ export const makeFetchOptions = (
129129
(typeof operation.context.fetchOptions === 'function'
130130
? operation.context.fetchOptions()
131131
: operation.context.fetchOptions) || {};
132-
if (extraOptions.headers) {
133-
if (extraOptions.headers.forEach) {
134-
(extraOptions.headers as Headers).forEach((value, key) => {
135-
headers[key] = value;
136-
});
137-
} else {
138-
for (const key in extraOptions.headers) {
139-
headers[key.toLowerCase()] = extraOptions.headers[key];
140-
}
141-
}
142-
}
143-
132+
if (extraOptions.headers)
133+
for (const key in extraOptions.headers)
134+
headers[key.toLowerCase()] = extraOptions.headers[key];
144135
const serializedBody = serializeBody(operation, body);
145136
if (typeof serializedBody === 'string' && !headers['content-type'])
146137
headers['content-type'] = 'application/json';

0 commit comments

Comments
 (0)