You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think this is a bug w/ the apollo memory cache sort of similar to #9543, but the opposite is happening. I have a paginated useQuery via typePolicies with a network-onlyfetchPolicy + a cache-firstnextFetchPolicy that is always returning cached data on secondary calls of the base page query.
i.e. component A spawns with a fresh new render cycle and calls the collection query getting fresh updated results, some procedures are then run and the data in the collection is updated in the database, then component B opens and runs a new version of the same collection query returning the exact same results as the first run in the data returned to the useQuery even though the network tab is showing the correct data from the execution of the query.
My guess is that the context.overwrite is false in this scenario and so the cached results are always being returned. I'm currently getting around this by skipping the initial fetch and calling refetch to get the most up to date data.
My useQuery call looks like this
fetchPolicy: 'network-only',
nextFetchPolicy: 'cache-first',
variables: { id }
})
with a paginated query looking like refetch({ variables: { after } })
and our typePolicies like
const typePolicies: TypePolicies = {
Parent: { // parent that query lives under
fields: {
connectionQuery: { // connection query that returns that data we're interested in
keyArgs: allArgsExcept(['after']),
merge: mergeByKey('edges', 'cursor')
}
}
}
}
One thing to note is that the data being returned in the connection looks something like
A new run of a useQuery with a fetchPolicy of network-only should always return the fetched data
Actual outcome:
The cached data is returned, probably due to the fetch policy/pagination code holding the results in cache so that queries with new args that aren't in the keyArgs array can be merged
How to reproduce the issue:
Versions
The text was updated successfully, but these errors were encountered:
Digging into this issue a little more and still not sure if it's a bug or not because we can actually handle it by checking if our pagination cursor is undefined (aka fetching from the start) and then always returning the incoming results in that case. The unusual part to me is that the existing data is still there in this case, but maybe that's to be expected. Let me know, and happy to close this out if it's all expected behavior
Hello,
I think this is a bug w/ the apollo memory cache sort of similar to #9543, but the opposite is happening. I have a paginated
useQuery
viatypePolicies
with anetwork-only
fetchPolicy
+ acache-first
nextFetchPolicy
that is always returning cached data on secondary calls of the base page query.i.e. component A spawns with a fresh new render cycle and calls the collection query getting fresh updated results, some procedures are then run and the data in the collection is updated in the database, then component B opens and runs a new version of the same collection query returning the exact same results as the first run in the data returned to the
useQuery
even though the network tab is showing the correct data from the execution of the query.My guess is that the
context.overwrite
is false in this scenario and so the cached results are always being returned. I'm currently getting around this by skipping the initial fetch and callingrefetch
to get the most up to date data.My useQuery call looks like this
with a paginated query looking like
refetch({ variables: { after } })
and our typePolicies like
One thing to note is that the data being returned in the connection looks something like
and we are merging either edges or nodes
Intended outcome:
A new run of a useQuery with a fetchPolicy of network-only should always return the fetched data
Actual outcome:
The cached data is returned, probably due to the fetch policy/pagination code holding the results in cache so that queries with new args that aren't in the keyArgs array can be merged
How to reproduce the issue:
Versions
The text was updated successfully, but these errors were encountered: