-
Notifications
You must be signed in to change notification settings - Fork 30
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
Cannot execute consecutive queries that would return the same data #405
Comments
I'm seeing the same issue. I initially thought it only happens when the server returns empty data, but good to know that it also happens for any data that is the same as last time. WIll switch to inmemory for now. |
Sad that we are not hearing anything from owners. This is a deal-breaker for us on switching to |
I wonder what causes this. There must be some side-effect that apollo-client is counting on to update the loading state? |
After taking a quick look into this issue, I found that the ObservableQuery implementation in apollo-client has a method called isDifferentFromLastResult which compares the previous and the new results when a query change happens. If the When I change a query using apollo-cache-inmemory this method is being called twice: In my case the data is the same (oldData = newData), but this method will return When I change a query using apollo-cache-hermes this method is being called only once: Because oldData=newData, and Basically, the "loading state" result is missing when using apollo-cache-hermes, that's why this logic breaks in apollo-client. When I modified this method in apollo-client to return I hope this info helps someone in fixing this issue. |
Summary:
If executing the same query two (or more) consecutive times that would return the same
data
, observers listening to events fromapollo-client
client.watchQuery
are not notified of the change. This leads to necessary UI updates not occurring. In particular,<Query>
component fromreact-apollo
does not re-render and stays in "loading" state.Here is a repro case:
Now, go to
index.js
, switchcache
toapollo-cache-inmemory
and try above again. It'll work just fine.Expected Behavior:
react-apollo
'sQuery
component, are always notified of the the query's network result, regardless of its content.apollo-cache-inmemory
functionality is matched.Actual Behavior:
Two (or more) consecutive queries that would return the exact same
data
do not trigger re-renders of components expecting changes to the store.The text was updated successfully, but these errors were encountered: