-
Notifications
You must be signed in to change notification settings - Fork 93
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
Fetch policies #75
Comments
Hi @jgoux here's a breakdown of each policy and how we support it: cache-firstIf you provide a cache to cache-and-networkThe In the example below I'm rendering both loading and data - best of both worlds, you could render the stale data but also have a loading indicator. Or if you wish, ignore the loading state if I've also implemented an effect to call onMount, that checks if the query result came from the cache to refetch it. function MyComponent() {
const { loading, error, data, cacheHit, refetch } = useQuery(QUERY)
useEffect(() => {
if (cacheHit) {
refetch()
}
}, [])
return (
{error && <div>Error!</div>}
{loading && <div>loading</div>}
{data && <div>{data}</div>}
)
} network-only
cache-onlyWe don't support this, I'm not sure there are any valid use-cases of this. no-cache
|
@bmullan91 - Could we take what you've written there and drop it in the |
This is now documented as part of the |
Hello again 😄 ,
Description
Do you have/intend to propose a fetchPolicy option in the same spirit as https://www.apollographql.com/docs/react/api/react-apollo.html#graphql-config-options-fetchPolicy ?
This is useful for controlling the UX. For example I often use a "cache-and-network" policy so a refetch of a query doesn't show a "loading" state again.
The text was updated successfully, but these errors were encountered: