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 stringifyVariables not stringifying toJSON values for scalars (#718)

* Fix stringifyVariables not stringifying toJSON values for scalars

Fix #717

* Update stringifyVariables toJSON test

authored by

Phil Plückthun and committed by
GitHub
762a819a 77e58254

+7 -2
+5
.changeset/stale-onions-check.md
··· 1 + --- 2 + '@urql/core': patch 3 + --- 4 + 5 + Fix stringifyVariables breaking on x.toJSON scalars.
+1 -1
packages/core/src/utils/stringifyVariables.test.ts
··· 29 29 30 30 it('stringifies dates correctly', () => { 31 31 const date = new Date('2019-12-11T04:20:00'); 32 - expect(stringifyVariables(date)).toBe(date.toJSON()); 32 + expect(stringifyVariables(date)).toBe(`"${date.toJSON()}"`); 33 33 }); 34 34 35 35 it('stringifies dictionaries (Object.create(null)) correctly', () => {
+1 -1
packages/core/src/utils/stringifyVariables.ts
··· 7 7 } else if (typeof x !== 'object') { 8 8 return JSON.stringify(x) || ''; 9 9 } else if (x.toJSON) { 10 - return x.toJSON(); 10 + return stringify(x.toJSON()); 11 11 } else if (Array.isArray(x)) { 12 12 let out = '['; 13 13 for (let i = 0, l = x.length; i < l; i++) {