TanStackT
TanStack6mo ago
6 replies
radical-lime

Query Keys for Infinite Queries

Hey! I'm using useInfiniteQuery for a really big list of posts, and I want to update a single post with queryClient.setQueryData. I thought I could do this with setQueryData(["posts", post.id], ...) but that's when I thought that the infinite query placed items as a separate query key. Can I make it do this, or would I have to do some weird stuff like send down just post IDs from the GET /posts endpoint and for each <Post /> have it's own useQuery({ queryKey: ["posts", post.id] }) but that seems really heavy on performance and doesn't feel straightforward. Can I somehow do this without having to update the whole list?
Was this page helpful?