docs(query-db-collection): document runtime QueryClient factory pattern#1667
docs(query-db-collection): document runtime QueryClient factory pattern#1667KyleAMathews wants to merge 5 commits into
Conversation
|
Caution Review failedAn error occurred during the review process. Please try again later. ✨ Finishing Touches🧪 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 |
More templates
@tanstack/angular-db
@tanstack/browser-db-sqlite-persistence
@tanstack/capacitor-db-sqlite-persistence
@tanstack/cloudflare-durable-objects-db-sqlite-persistence
@tanstack/db
@tanstack/db-ivm
@tanstack/db-sqlite-persistence-core
@tanstack/electric-db-collection
@tanstack/electron-db-sqlite-persistence
@tanstack/expo-db-sqlite-persistence
@tanstack/node-db-sqlite-persistence
@tanstack/offline-transactions
@tanstack/powersync-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/react-native-db-sqlite-persistence
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/tauri-db-sqlite-persistence
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
|
Size Change: 0 B Total Size: 125 kB ℹ️ View Unchanged
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughChangesRuntime QueryClient documentation
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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 |
|
Size Change: 0 B Total Size: 4.22 kB ℹ️ View Unchanged
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/collections/query-collection.md`:
- Around line 85-86: Add a brief note near the example using
getRequestQueryClient() clarifying that it is application-specific and must be
implemented by the application to return the current request- or route-scoped
QueryClient.
- Line 105: Reword the statement near the QueryClient factory documentation to
avoid implying that the factory enforces isolation; explain that it allows SSR
and request-scoped code to avoid sharing a global QueryClient only when callers
provide a scoped instance.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 888e5b05-76b5-4693-aaa9-0957e617eb3d
📒 Files selected for processing (2)
.changeset/document-runtime-query-client-factory.mddocs/collections/query-collection.md
Summary
Document the recommended factory pattern for using
@tanstack/query-db-collectionwith runtime-scopedQueryClientinstances. This shows users in SSR, TanStack Start, test, and multi-tenant environments how to avoid sharing a module-globalQueryClient.Approach
QueryClient.QueryClientand returnsqueryCollectionOptions(...).@tanstack/query-db-collectionbecause the docs are package-specific.Key Invariants
queryCollectionOptionsstill receivesqueryClientwhen collection options are created.QueryClient.Non-goals
Trade-offs
The docs recommend a plain factory function rather than adding API sugar. This keeps the guidance usable today while leaving room for a future API only if repeated examples show that boilerplate or type inference becomes a problem.
Verification
pnpm prettier --write docs/collections/query-collection.md pnpm exec tsx scripts/verify-links.ts git diff --checkAlso attempted:
pnpm test:docs pnpm testpnpm test:docsfailed because the package script runsnode scripts/verify-links.ts, and Node rejected the.tsentrypoint withERR_UNKNOWN_FILE_EXTENSION. Running the same script withtsxpassed.pnpm testfailed inpackages/offline-transactionsbecause Vite could not resolve the@tanstack/dbpackage entry. This appears unrelated to this docs-only change.Files changed
docs/collections/query-collection.md: Adds runtimeQueryClientfactory guidance and examples..changeset/document-runtime-query-client-factory.md: Adds a patch changeset for@tanstack/query-db-collectiondocs.Summary by CodeRabbit
QueryClientparameterization) and advice for memoizing collections per scoped client and parameter set for stable behavior in SSR/tests/multi-tenant apps.