Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useQuery - data and error not updating with refetch #9059

Open
viduli-prime opened this issue Nov 14, 2021 · 2 comments
Open

useQuery - data and error not updating with refetch #9059

viduli-prime opened this issue Nov 14, 2021 · 2 comments
Labels
🔍 investigate Investigate further
Milestone

Comments

@viduli-prime
Copy link

viduli-prime commented Nov 14, 2021

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
@bignimbus bignimbus added the 🔍 investigate Investigate further label Dec 7, 2022
@bignimbus
Copy link
Contributor

Hi @viduli-prime 👋🏻 thanks for your patience! This appears to be similar to #8833 so next time we take a fresh look at refetch we'll keep this issue in mind. Again, we really appreciate your patience!

@denis-sokolov
Copy link

(Connecting to a related historic ticket for future readers on both sides.)

@jerelmiller jerelmiller added this to the Release 4.0 milestone Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔍 investigate Investigate further
Projects
None yet
Development

No branches or pull requests

4 participants