TanStackT
TanStack•2mo ago•
4 replies
urgent-maroon

How to populate on-demand QueryCollection with initial data?

I have some query collections that are initialized with syncMode: 'on-demand', so they do not fetch initial data. I also am loading records such as users which includes their address record as part of the payload. I'd like to insert the address into the address collection using direct writes with writeUpsert, but am getting: SyncNotInitializedError: Collection must be in 'ready' state for manual sync operations. Sync not initialized yet.
If the address record isn't present in the addresses store, then it can't later be updated šŸ¤” I could call await preload() on the address collection prior to upserting with a dummy queryFn that returns [] but that seems wrong.

Maybe this is a bug? Or maybe i should file a issue for consideration before 1.0?
Was this page helpful?