-
Notifications
You must be signed in to change notification settings - Fork 687
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
[doc]: recommend pairs of Apollo fetch-policy and conditionals in the render flow #2635
Comments
Hi @brendanfalkowski. Thank you for your report. Please, add a comment to assign the issue:
|
This isn't an answer to the problem, but I want to point out that in v3 there seems to be a way to override the default fetch policy when initializing your client: https://www.apollographql.com/docs/react/api/core/ApolloClient/#example-defaultoptions-object |
This is a very good suggestion. You're right, |
Created PWA-869 |
Clearing my assignment to give the community an opportunity to pick up this issue if they are interested |
Describe the request
Apollo Client can be frustrating during development. We had two problems:
As a workaround during dev, we started writing
fetch-policy: network-only
on every request and wrote our render flows with extreme simplicity:Almost all of our code is written this way, but we understand that once we begin to utilize other
fetch-policy
values that Apollo Client has some quirks around whatdata/!data
andloading
mean when the cache is available to return data and/or network calls are in flight.We want to run a tight ship, but it feels like bad API design if we need to have different conditionals like
if (loading && !data)
depending on the fetch-policy being applied. The risk of a developer copypasta-ing and not understanding the relationship between fetch-policy and render flow is easy to overlook.As I understand it Apollo Client v3 changes how some of this will work. It would be nice if documentation contained a table of
I'd guess there are only a few patterns actually needed, and this documentation would save developers learning what/why Apollo does before they spread bad patterns around the site.
Possible solutions
A new page that links from the last section here:
https://magento.github.io/pwa-studio/technologies/basic-concepts/client-side-caching/
Screenshots
If applicable, add screenshots to help explain the problem.
Please let us know whether this is a new topic or a topic change request:
The text was updated successfully, but these errors were encountered: