Closed
Description
I have a query like this,
const { data, error, refetch } = useQuery(QUERY, { fetchPolicy: "network-only", nextFetchPolicy: "network-only" })
When I call refetch
and if the API returns an error, both data
and error
don’t update. error
is null, and data
holds the values from the last successful fetch. Although, the promise returned from refetch
rejects with the error. Is that the intended behavior? If so, how do I get data to clear when the api returns an error?
Intended outcome:
I would expect data
to be null
and error
to contain the error.
Actual outcome:
data
and error
contain the values from the previous fetch.
How to reproduce the issue:
Try a query like the above, API should return a successful result on the first run, and should return an error on the second run. Second run should be triggered by refetch
Versions
System:
OS: Linux 5.4 Linux Mint 20.1 (Ulyssa)
Binaries:
Node: 14.17.1 - ~/.nvm/versions/node/v14.17.1/bin/node
Yarn: 1.22.11 - ~/.nvm/versions/node/v14.17.1/bin/yarn
npm: 6.14.13 - ~/.nvm/versions/node/v14.17.1/bin/npm
Browsers:
Chrome: 94.0.4606.81
Firefox: 90.0.2
npmPackages:
@apollo/client: ^3.4.11 => 3.4.11