Bulk prefetching
Hello, I’m using tanstack start, router and query to build a pretty simple app. My app has primary content, lets say blogposts, and secondary content, lets say comments.
In my route’s loader function I prefetch the posts and await them (context.queryclient.ensurequerydata). Using the posts, I prefetch the comments (in bulk) and seed the data for comments on singular posts. I do not await this call, as it’s secondary data.
I render my page with posts, and with each post a chip that displays the amount of comments wrapped in a suspense. The chip component has a suspensequery in it to fetch the amount of comments for that particular post.
I am hoping for the query in the chip not to make an external call, as I’m seeding the data in bulk in the loader function. However, because I’m not awaiting this bulk call, and the individual chips are rendered before the bulk call is finished, the chips all fire individual calls.
Is there a way to deal with this? I really don’t want to await the bulk call, because like I said, it’s secondary data that I want to suspense. I run my app in SPA mode and don’t use SSR.
2 Replies
genetic-orange•3w ago
this question would benefit from some paragraphs 😄
but even more so, it would benefit from a reproducer that shows what you are doing here
vicious-goldOP•3w ago
Sorry, I typed all of this on my phone right before I went to bed.
I shall give a clear example tonight.
Is there an environment where I can create a reproduction?