react-apollo-hooks icon indicating copy to clipboard operation
react-apollo-hooks copied to clipboard

`useQuery` doesn't work correctly if `variables` is set to `undefined`

Open jack-sf opened this issue 6 years ago • 0 comments

... but it works okay if it is set to an empty object ({}).

Issues that happen when you do variables: {}:

  1. https://github.com/trojanowski/react-apollo-hooks/issues/140

  2. Our case:

Have a hook like

  const response = useQuery<Data>(QUERY, {
    fetchPolicy: 'cache-first',
  });

If you call it for the first time, it gets the data from network and everything is ok.

But if you unmount and mount the component, then data is set properly (to the cached version), loading correctly is false, but networkStatus is 8 (NetworkStatus.error), even though error and errors properties are undefined.

Happens on both 0.4.5 and 0.5.0 .

jack-sf avatar Jul 19 '19 20:07 jack-sf