-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
fix: don't update dataUpdateCount when setting initial data #9743
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: c7031cf The changes in this PR will be included in the next version bump. This PR includes changesets to release 19 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 |
WalkthroughApplies initialData to queries by updating the query state directly (avoiding setData) to prevent accidental dataUpdateCount increments; adds a test verifying prefetched-query + initialData behavior and observer refetch; includes a changeset noting the isFetchedAfterMount fix. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor App
participant Query as Query
participant Observer as QueryObserver
participant State as QueryState
participant Fetcher as Fetch
App->>Query: prefetch() (no data)
Query->>State: create pending state (data: undefined)
App->>Observer: mount(initialData)
Observer->>Query: setOptions(initialData)
Query->>State: setState(successState(initialData))
Note right of State #dff0d8: dataUpdateCount remains 0\nfetchMeta/fetchFailure cleared
App->>Observer: observer.refetch()
Observer->>Query: fetch()
Query->>Fetcher: network fetch
Fetcher-->>Query: resolved data
Query->>State: setData(fetched) -- increments dataUpdateCount
Note right of State #f7ecb5: isFetchedAfterMount becomes true
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧬 Code graph analysis (1)packages/query-core/src/query.ts (1)
🔇 Additional comments (3)
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 426c02c
☁️ Nx Cloud last updated this comment at |
…tchedAfterMountFix
…/query into diid/fetchedAfterMountFix
…tchedAfterMountFix
…/query into diid/fetchedAfterMountFix
🎯 Changes
This introduces a check when updating
dataUpdateCountso that it isn't updated when setting initial data. This in turn fixes theisFetchedAfterMountbug discussed in #9656fixes #9656
✅ Checklist
pnpm test:pr🚀 Release Impact
Summary by CodeRabbit
Bug Fixes
Tests
Chores