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
Firstly, thank you for your work on this library! I am currently using a pull approach to seed the query cache, and I have encountered a specific issue. When a user enters a page, I call ensureQueryData, passing in an initialData value, which may be undefined. The issue I am facing is that ensureQueryData always triggers a fetch when the data is not already in the cache, even when initialData is provided (non undefined).
Below is a simplified example in pseudo-code to illustrate the issue:
constquery=queries.postById.getOptions(id);awaitqueryClient.ensureQueryData({
...query,// here I search inside list queries to find an existing post to be on the initial data// even when I have a post, the fetch is executedinitialData: utils.findInPages(queries.postList.getKey(),byId(id)),});
Describe the bug
Firstly, thank you for your work on this library! I am currently using a pull approach to seed the query cache, and I have encountered a specific issue. When a user enters a page, I call
ensureQueryData
, passing in aninitialData
value, which may beundefined
. The issue I am facing is thatensureQueryData
always triggers a fetch when the data is not already in the cache, even wheninitialData
is provided (non undefined).Below is a simplified example in pseudo-code to illustrate the issue:
Your minimal, reproducible example
Stackblitz
Steps to reproduce
https://stackblitz.com/edit/vitejs-vite-cnkcntdk?file=src%2FApp.tsx
Expected behavior
Since I am providing
initialData
, the expected behavior is for the query client to store theinitialData
in the cache and bypass the fetch process.How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
Tanstack Query adapter
react-query
TanStack Query version
5.62.3
TypeScript version
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: