-
Hey all, running into an issue with trying to persist queries using query/packages/query-core/src/hydration.ts Lines 97 to 109 in 1c8d978 shouldDehydrateQuery function returns false the query is skipped for persistence but the state is in fact stored.
This is all working fine with normal const dehydrateOptions: DehydrateOptions = {
shouldDehydrateQuery,
};
export const shouldDehydrateQuery = (query: Query): boolean => {
if (query.queryKey.length === 0) return false;
if (query.state.status !== "success") return false;
// eslint-disable-next-line prettier/prettier
const keysToDehydrate = [
"some-key-here",
"some-key-here-used-in-infinityQuery"
];
const stringKey = String(query.queryKey[0]);
return keysToDehydrate.includes(stringKey);
}; Curious if anyone has found a solution for this? at the moment I can just "whitelist" all useInfinityQuery for persistence, but just making sure I am not doing anything wrong. Thank you all |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
if
not sure I understand what you are referring to here, sorry. infinite queries and "normal" queries are no different. it's just that their |
Beta Was this translation helpful? Give feedback.
if
shouldDehydrateQuery
returns false, the query is not persisted to the external storage. Not sure what you mean with "state is in fact stored". Stored where? The data remains in the queryCache in memory if that's what you mean, yes. The persisters never delete anything from the queryCache.