Repository: FormidableLabs/urql (ts)

Issue:
Error in stringifyVariables during mutation
We recently updated our version of urql from 1.3.1 to 1.6.3 and our mutations started breaking.

The error logged in the console is
```
Uncaught TypeError: Cannot read property 'length' of undefined
    at stringify (stringifyVariables.ts:36)
    at stringify (stringifyVariables.ts:35)
    at stringify (stringifyVariables.ts:35)
    at stringify (stringifyVariables.ts:35)
    at stringify (stringifyVariables.ts:35)
    at stringifyVariables (stringifyVariables.ts:49)
    at createRequest (request.ts:36)
    at useMutation.ts:47
```
We have Momentjs fields in the object that is being passed into the mutation variables and it appears this is where the embedded stringify is breaking.  Version 1.3.1 was able to stringify these just fine with the default string version of a Moment being an ISO date.

Any guidance would be appreciated.
refetch not triggered when variable changed
I have the following code to fetch data:
```
  const [{ data, fetching, error }, fetchMovements] = useQuery<
    Get_MovementsQuery
  >({
    query: GET_MOVEMENTS,
    variables: { skip: startRow, first: rowNumber, orderBy, where: filter },
    requestPolicy: 'cache-and-network'
  })
```

Where filter is an object with all the different filter options. 

I have a datetime-range filter. The structure of the filter object for that case looks like this:
```
{
    date: {
      gte: DateTime,
      lte: DateTime
    }
  }
```

When changing one of the values for the first time, it correctly detects a change in the variables and triggers a refetch, but when changing the same datetime another time, it doesn't cause a refetch.

If necessary I can provide a reproduction.

Maybe it's also just my own stupidity, but I am pretty sure it's related to urql.

I am using the latest version with the urql-graphexchange. 

Pull request:
fix problem with stringifying date objects
For some reason when I tried to include the library locally I got an error about Invalid hook calls:

`Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:`

So I was not able to test if it fixes those for sure

This possibly: 
fixes #479 and fixes #478 

Patch:
diff --git a/src/utils/stringifyVariables.ts b/src/utils/stringifyVariables.ts
index 38c060b2..e8a2f3f1 100644
--- a/src/utils/stringifyVariables.ts
+++ b/src/utils/stringifyVariables.ts
@@ -9,6 +9,8 @@ const stringify = (x: any): string => {
     return JSON.stringify(x);
   } else if (x === null) {
     return 'null';
+  } else if (x.toJSON) {
+    return x.toJSON();
   }
 
   let out = '';


Test patch:
diff --git a/src/utils/stringifyVariables.test.ts b/src/utils/stringifyVariables.test.ts
index e08c21b6..9e1e61a7 100644
--- a/src/utils/stringifyVariables.test.ts
+++ b/src/utils/stringifyVariables.test.ts
@@ -28,3 +28,9 @@ it('throws for circular structures', () => {
     stringifyVariables(x);
   }).toThrow();
 });
+
+it('stringifies date correctly', () => {
+  expect(stringifyVariables(new Date('2019-12-11T04:20:00'))).toBe(
+    '2019-12-11T04:20:00.000Z'
+  );
+});