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

Debugging why an observed query is refetched #2397

Open
Tracked by #2331
lwasyl opened this issue Jun 25, 2020 · 2 comments
Open
Tracked by #2331

Debugging why an observed query is refetched #2397

lwasyl opened this issue Jun 25, 2020 · 2 comments

Comments

@lwasyl
Copy link
Contributor

lwasyl commented Jun 25, 2020

In UI tests we're enqueueing responses for the network requests that we expect. However, sometimes Apollo makes additional requests that we don't expect (e.g. because a query doesn't fetch ID). What's the best way to monitor why Apollo is considering a query stale and in need for a network request to refetch it? I'm looking for something where I can e.g. log that a certain query is being observed and Apollo will now make a request for it, because some specific event happened/cache keys got modified

@lwasyl lwasyl changed the title Debugging why and observed query is refetched Debugging why an observed query is refetched Jun 25, 2020
@eyalw
Copy link

eyalw commented Nov 20, 2020

So how can one debug this? I have this problem...

@martinbonnin
Copy link
Contributor

martinbonnin commented Nov 20, 2020

Hi @eyalw 👋 that's unfortunately not easy and definitely something we want to improve.

There's some information there: https://www.apollographql.com/docs/android/essentials/normalized-cache/#troubleshooting

Also latest version (2.4.5) included #2751. I'm not sure this would be reachable from apolloClient.query but you can try to read the cache directly with your query (apolloClient.apolloStore.read) and get the missing key from the exception.

If nothing helps, feel free to open a separate issue with your schema and queries and we investigate together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants