T
TanStack2h ago
rare-sapphire

Tanstack Query Dependencies

Hello, I've been wanting to use Tanstack DB in my project which also uses Tanstack Router and Tanstack Query, but I've been struggling to figure out how to structure createCollection with queries that have a dependency on a different query. In particular, I use versioned endpoints to manage CDN caching, so most of the queries I want to use to create collections depend on a db-version query which has to run before them. This creates a problem since it seems like collections really want to be defined in the global namespace (so they can be used directly inside live queries), but it isn't possible to encapsulate this dependency chain with queryCollectionOptions since there's no way for the db version to get passed from the db-version query into the statically defined query inside queryCollectionOptions. My latest thought is to use createCollection without queryCollectionOptions and have my queries direct write the data in their onSuccess handler from my route loader, but I'm not sure how this will impact the collection status, and I'm not thrilled about having to step outside of queryCollectionOptions. Is there a better pattern for this that I'm missing?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?