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.

fix(core): Replace File/Blob objects with null in serialized variables (#3169)

authored by

Phil Pluckthun and committed by
GitHub
8b37c221 a2bb8eac

+12 -7
+5
.changeset/afraid-seas-arrive.md
··· 1 + --- 2 + '@urql/core': patch 3 + --- 4 + 5 + Replace `File` and `Blob` objects with `null` in variables if multipart request will be started.
+1 -1
packages/core/src/internal/fetchOptions.test.ts
··· 149 149 ...body, 150 150 variables: { 151 151 ...body.variables, 152 - file: { __key: expect.any(String) }, 152 + file: null, 153 153 }, 154 154 }); 155 155
+1 -6
packages/core/src/utils/variables.test.ts
··· 40 40 41 41 it('stringifies files correctly', () => { 42 42 const file = new File([0] as any, 'test.js'); 43 - Object.defineProperty(file, 'lastModified', { value: 123 }); 44 43 const str = stringifyVariables(file); 45 - expect(str).toBe(stringifyVariables(file)); 46 - 47 - const otherFile = new File([0] as any, 'otherFile.js'); 48 - Object.defineProperty(otherFile, 'lastModified', { value: 234 }); 49 - expect(str).not.toBe(stringifyVariables(otherFile)); 44 + expect(str).toBe('null'); 50 45 }); 51 46 }); 52 47
+5
packages/core/src/utils/variables.ts
··· 18 18 } 19 19 out += ']'; 20 20 return out; 21 + } else if ( 22 + (FileConstructor !== NoopConstructor && x instanceof FileConstructor) || 23 + (BlobConstructor !== NoopConstructor && x instanceof BlobConstructor) 24 + ) { 25 + return 'null'; 21 26 } 22 27 23 28 const keys = Object.keys(x).sort();