-
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
Can no longer remove active queries by setting there nextFetchPolicy to standby #11217
Comments
Curious, I don't think that was an intended change. As for now, you could use @nonreactive, or if you really only want to read from the cache and never want cache updates, just skip using the function useReadQueryOnce(query, variables) {
const client = useApolloClient()
return useMemo(() => {
return client.readQuery({ query, variables })
}, [/* adjust your dependency array in a way that makes sense for you*/])
} |
Thanks @phryneas for the quick reply! I'm not sure the But the |
Oh wow, ironically we'd been using
Per this blog post but it stopped working, probably in 3.8... But, unlike @jrans , moving to |
@stephenh |
Hi @phryneas ! I used @jrans sandbox to repro that https://codesandbox.io/s/active-queries-3-8-3-forked-kjq3x3?file=/src/index.jsx:0-1894 But I basically added an explicit cache update:
And with |
My originally reported issue is fixed with the latest version. Thanks team. @stephenh I'm unsure on what your considering as a bug. The |
@jrans huh, I guess you're probably right... The blog post that I linked to, only mentioned "nextFetchPolicy: cache-first" for turning off network requests to refetch the data, not completely disconnect from the cache... That said, for the 3.7-ish version of Apollo we were on, it definitely /did/ disconnect from the cache, which ngl was confusing, but we were relying on that behavior. Now that we have standby, which seems new?, specifically for this purpose, cache-first not being "bug compatible" with the older version makes sense. Thanks! |
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
On updating
@apollo/client
fromv3.7.17
tov3.8
we noticed a huge influx in the number of "Active" queries when opening our app in the Apollo Client Dev Tools.For context, we use a query in a shared hook that is frequently used but we have taken care to set the fetch policies of the query to be
{ fetchPolicy: 'cache-first', nextFetchPolicy: 'standby' }
so that uses of the query aren't subscribed to cache updates. When a mutation is made, all active queries have to check whether they need to update and re-render and that tanks performance.I've looked at the in the ./CHANGELOG.md to see if there are any breaking changes but nothing seems to mention
nextFetchPolicy: 'standby'
effect changing for useQuery.Is there another recommended way to remove unsubscribe queries and prevent them from being "Active"?
Link to Reproduction
https://codesandbox.io/s/active-queries-3-8-3-cw3jk3?file=/src/index.jsx
Reproduction Steps
@apollo/client
to3.7.17
it will read 0 as expected.The text was updated successfully, but these errors were encountered: