-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Partial data returned on error after resetting cache #11938
Comments
Hey @TuurDutoit 👋 We are in the middle of finalizing our 3.11 release and will try and take a look shortly after. Thanks for submitting the issue with a reproduction! |
Another interesting find: if I add |
@jerelmiller I saw that 3.11 was released. Have you had a chance to look into this yet? |
Hey @TuurDutoit 👋 I just opened #11984 which should fix the issue. Turns out it didn't have much to do with Funny enough, I was able to reproduce this with 2 refetches as opposed to 3. I suspect it took 3 clicks on your reproduction because Could you try the following snapshot release to see if it fixes the issue in your actual app?
We'll either get this out with 3.11.3 or 3.11.4. |
@jerelmiller That does seem to fix it in our app! |
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Issue Description
In our app,
useQuery
sometimes returns partial data after resetting the cache (client.resetStore()
) and receiving an error.We have a React Native app that uses Apollo for most data fetching. Our Apollo client is initialized like so:
Note that the default
errorPolicy
isnone
and the defaultreturnPartialData
isfalse
.We have a home screen that fetches some data with a
useQuery
hook. In our settings screen, it's possible to change your language and log out, among other things. Both these actions will cause the Apollo cache to be cleared (client.resetStore
), to ensure we're not saving any data from other users or data in the wrong language. This in turn causes the home screen query to refetch automatically.If you do so, and our GraphQL API returns an error with partial data while refetching the home screen query,
useQuery
suddenly returns the partial data. With our Apollo client config,useQuery
should never return partial data.Successful query:
Failed query:
After
client.resetStore()
and error from API on refetch:We use
@apollo/client
3.7.7 currently, but I've tried on the latest (3.10.8), with the same result. The linked example is also using the latest version.Link to Reproduction
https://codesandbox.io/p/devbox/peaceful-hopper-mtpd9x
Reproduction Steps
Click the "Reset cache" button a few times in quick succession. For me, it always happens after 3 clicks. I'm not sure why that's needed in this simple example - in our app, a single
client.resetStore()
will trigger the issue.Expected outcome
Raw data
is alwaysundefined
Actual outcome
At some point, it becomes an object, with some of the requested data (notice how
name
is missing, breaking the list!)Screen recording
Screen.Recording.2024-07-09.at.16.26.35.mov
@apollo/client
version3.7.7
The text was updated successfully, but these errors were encountered: