-
Notifications
You must be signed in to change notification settings - Fork 686
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
[bug]: Home Page query is not fetching from network/updating cache #2230
Comments
During development, we started passing Docs for this do not exist: apollographql/apollo-client#1626 But somebody blogged it: https://medium.com/@galen.corey/understanding-apollo-fetch-policies-705b5ad71980 We have a pre-launch ticket to review all these, and consider where |
This is how
Actually, if we code the components correctly we won't have to use the service worker for this (that's what displays the "new version available" toast), we can just trust that Apollo will "show" the correct thing, as soon as it can. In this case it will render cached data first, make a network request, and then re-render with any changed data. Let's modify the title/contents of this ticket to be the specific behavior you noticed, ie "Home Page query is not fetching from network/updating cache", etc. And then @awilcoxa and @Jordaneisenburger can help get it prioritized. |
Moved to Jira backlog for prioritization in grooming |
Marked as P2S1, needs additional investigation |
I've opened a draft PR which implements the @sirugh @jimbo there are a number of "bugs" or "issues" with how Apollo handles the There's a lot of closed & open issues on Apollo for this, such as apollographql/react-apollo#3361, there is also a comment from one of the contributors which states this is actually an expected outcome, and thus would need to be resolved by a feature request: apollographql/react-apollo#2739 (comment) The solution I found, which works in my initial testing is to expand the
From my testing this works for completely uncached requests, cached requests with no data changes from Magento and finally cached requests with changes in Magento. You'll see the original cached data render, then after the GraphQL requests completes the new content will be automatically rendered. I couldn't find a concise opinion on how to handle this from my research so wanted to hear your thoughts on whether this is an adequate solution. |
|
- Remove redundant loading flag and null response on no data
- Add page loading state to app context - Add loading icon into header - Trigger page loading from CMS root component
- Add test coverage for new isPageLoading in talon & header
* Update Home Page content after cache hit (#2230) * Update Home Page content after cache hit (#2230) - Remove redundant loading flag and null response on no data * PWA-471: Update Home Page content after cache hit (#2230) - Add page loading state to app context - Add loading icon into header - Trigger page loading from CMS root component * PWA-471: Update Home Page content after cache hit (#2230) * PWA-471: Update Home Page content after cache hit (#2230) - Add test coverage for new isPageLoading in talon & header * PWA-471: Update Home Page content after cache hit (#2230) * PWA-471: Update Home Page content after cache hit (#2230) * PWA-471: Update Home Page content after cache hit (#2230)
@jimbo testing locally, it looks like network status is solely It seems like the approach @davemacaulay came up with is the best and only option, unless if Apollo were to incorporate this use case into the API |
Describe the bug
I've noticed that Apollo in PWA Studio isn't updating its local cache (
apollo-cache-persist
in localStorage) from the network (for page content in my case), it's only serving from cache. This means that making changes to a page doesn't ever get reflected in the app until this cache is manually cleared.To reproduce
Steps to reproduce the behavior:
apollo-cache-persist
Expected behavior
On the first reload, the old data should be displayed, but in the background a request should be sent to the server to get the latest version of the homepage. The returned data should then being pushed into the localStorage cache, so that on the second reload (either a user is prompted through an action similar to "There is a new version of the app available, please refresh", or they just happen to reload again), they will see the new data on the page
Possible solutions
The solution is to make a network request to update Apollo cache after it has server up its cache. I'm not familiar enough with Apollo to say how this would be done specifically
Please complete the following device information:
Please let us know what packages this bug is in regards to:
venia-concept
venia-ui
The text was updated successfully, but these errors were encountered: