docs({react,preact,solid,vue}-query/useQuery): add 'initialDataUpdatedAt' to the seeding example - #11579
docs({react,preact,solid,vue}-query/useQuery): add 'initialDataUpdatedAt' to the seeding example#11579sukvvon wants to merge 1 commit into
Conversation
…dAt' to the seeding example
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: TanStack/query/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (9)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe PR updates ChangesInitial data timestamp documentation
Priority: ⬇️ Low Estimated code review effort: 1 (Trivial) | ~5 minutes Change: Other Merge Risk: ⚪ Minimal · up to This update documents more accurate seeded-query freshness behavior without changing published runtime code, so no merge-blocking production risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
View your CI Pipeline Execution ↗ for commit 34a1eec
☁️ Nx Cloud last updated this comment at |
🚀 Changeset Version PreviewNo changeset entries found. Merging this PR will not cause a version bump for any packages. |
size-limit report 📦
|
🎯 Changes
The "Seeding a detail query from an already-cached list"
@examplein each ofreact-query,preact-query,solid-query, andvue-query'suseQuery.tsusedinitialDatato look up a detail item from an already-cached list query, but didn't setinitialDataUpdatedAt.Without it, the seeded data's
dataUpdatedAtdefaults toDate.now()(packages/query-core/src/query.ts), so if astaleTimeis later set on the query, staleness is measured from "now" instead of from when the source list was actually fetched — which can make stale seeded data look fresh for longer than intended.This is the pattern the framework's own guide already documents and recommends (
docs/framework/react/guides/initial-query-data.md, "Initial Data from the cache withinitialDataUpdatedAt" — "Instead of using an artificialstaleTime... it's suggested that you pass the source query'sdataUpdatedAttoinitialDataUpdatedAt"), with the exact samegetQueryState(...)?.dataUpdatedAtcall. This PR brings theuseQueryreference example in line with that guide.Added
initialDataUpdatedAt: () => queryClient.getQueryState(['posts'])?.dataUpdatedAtto the example in all four adapters, and a sentence explaining why.✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request.🚀 Release Impact
Summary by CodeRabbit
staleTimeis measured from the original list fetch when usinginitialDataUpdatedAt.