Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Revert "support Headers being passed in fetchOptions"

This reverts commit dc509cc25f2d37c65aeb0f93ab0055a0a2e80d27.

+3 -41
-5
.changeset/fluffy-poets-protect.md
··· 1 - --- 2 - '@urql/core': patch 3 - --- 4 - 5 - Correctly support the `Headers` class being used in `fetchOptions`
-24
packages/core/src/internal/fetchOptions.test.ts
··· 107 107 `); 108 108 }); 109 109 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 - 134 110 it('creates a GET request when preferred for query operations', () => { 135 111 const operation = makeOperation(queryOperation.kind, queryOperation, { 136 112 ...queryOperation.context,
+3 -12
packages/core/src/internal/fetchOptions.ts
··· 129 129 (typeof operation.context.fetchOptions === 'function' 130 130 ? operation.context.fetchOptions() 131 131 : 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]; 144 135 const serializedBody = serializeBody(operation, body); 145 136 if (typeof serializedBody === 'string' && !headers['content-type']) 146 137 headers['content-type'] = 'application/json';