Skip to content
Source
Sign inSign up
TanStack/db

feat(query-db): support eager initial data #1683

MergedKyleAMathews(GitHub profile, opens in a new tab)merged 5 commits intomain fromrefs/pull/1683/headmerged by KyleAMathews(GitHub profile, opens in a new tab)

Showing 6 changed files with 64 additions and 1 deletion (loading 4).

x
0 of 6 viewed, 6 left
7 additions and 0 deletions.changeset/young-cats-initialize.mdAdded
View file
@@ -0,0 +1,7 @@
+---
+'@tanstack/query-db-collection': minor
+---
+​
+Add eager collection support for TanStack Query `initialData` and `initialDataUpdatedAt`, including wrapped response projection and collection-local initialization on shared QueryClient instances.
+​
+QueryClient-default `placeholderData` no longer materializes as collection rows, and QueryClient-default `initialData` no longer seeds on-demand subset observers.
57 additions and 1 deletiondocs/collections/query-collection.mdModified
View file
@@ -200,6 +200,8 @@
- `refetchOnReconnect`: Whether to refetch when the network reconnects
- `refetchOnMount`: Whether to refetch when the observer mounts
- `networkMode`: Query network mode
+- `initialData`: Initial Query response for eager collections
+- `initialDataUpdatedAt`: Timestamp used by TanStack Query to determine initial data freshness
- `meta`: Metadata passed to the query function context. Query Collections may add `loadSubsetOptions` for on-demand queries.
​
```ts
@@ -237,7 +239,7 @@
- `subscribed` (Query Collection owns the observer subscription lifecycle)
- `structuralSharing` and `notifyOnChangeProps` (managed by Query Collection synchronization)
​