-
Notifications
You must be signed in to change notification settings - Fork 107
feat: add exact refetch targeting and improve utils.refetch() behavior #552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 401e7c7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
More templates
@tanstack/angular-db
@tanstack/db
@tanstack/db-ivm
@tanstack/electric-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
…chType Changes: - Use queryObserver.refetch() for all refetch calls (both utils and internal handlers) - Bypasses enabled: false to support manual fetch patterns (matches TanStack Query hook behavior) - Fixes clearError() to work even when enabled: false - Return QueryObserverResult instead of void for better DX - Remove refetchType option - not needed with exact targeting via observer - Add tests for clearError() exact targeting and throwOnError behavior - Update docs to clarify refetch semantics With exact targeting via queryObserver, refetchType filtering doesn't add value. Users always want their collection data refetched, whether from utils.refetch() or internal mutation handlers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Hey @lucasweng! Sorry for not getting to this for so long! I/we somehow missed it. Thanks for tackling this issue. I reviewed your PR and made some refinements based on a careful analysis of the requirements and TanStack Query's behavior. Here's what changed: Changes Made
This was the key insight: we need different behavior for imperative refetch vs batch refetch operations.
After discussion, we realized refetchType doesn't add value with exact targeting:
The Core Issue The original issue was about preventing cascade refetches. Your solution with exact: true solved that perfectly! The additional changes ensure Let me know if you have any questions about these changes! |
Resolves #537
Summary
utils.refetch()to bypassenabled: falsefor imperative control (matches TanStack Query hook behavior)QueryObserverResultfromutils.refetch()for better DXrefetchTypeoption - not needed with exact targeting via observerKey Changes
queryObserver.refetch()which targets only this collection (no cascade)clearError()QueryObserverResultinstead ofvoidso users can inspect the resultrefetchTypesince exact targeting via observer makes it unnecessaryTest Plan
clearError()exact targetingthrowOnErrorbehaviorenabled: falsebypass