Skip to content

Conversation

@sukvvon
Copy link
Contributor

@sukvvon sukvvon commented Feb 7, 2026

🎯 Changes

Add a test to verify that getOptimisticResult updates currentResult when the query data has changed between renders (e.g., via setQueryData).

βœ… Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

πŸš€ Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

@changeset-bot
Copy link

changeset-bot bot commented Feb 7, 2026

⚠️ No Changeset found

Latest commit: 717d5d8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 7, 2026

πŸ“ Walkthrough

Walkthrough

This PR adds a test case to validate that QueryObserver.getOptimisticResult correctly reflects updated cached data after queryClient.setQueryData is called, ensuring the observer properly tracks cache changes.

Changes

Cohort / File(s) Summary
Test Addition
packages/query-core/src/__tests__/queryObserver.test.tsx
Adds a test verifying that getOptimisticResult returns updated data after the cache is modified via queryClient.setQueryData.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

package: query-core

Poem

🐰 A curious test hops through the cache,
Checking if observers match the facts,
When data updates, optimistic and bright,
The results align, everything's right! ✨

πŸš₯ Pre-merge checks | βœ… 3
βœ… Passed checks (3 passed)
Check name Status Explanation
Title check βœ… Passed The title accurately describes the primary change: adding a test for getOptimisticResult updating currentResult with changed data in queryObserver.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check βœ… Passed The pull request description follows the template structure with all required sections completed. The Changes section clearly describes the test being added, the Checklist shows both contributing guide and testing steps have been completed, and Release Impact correctly identifies this as a dev-only change.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • πŸ“ Generate docstrings
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link

nx-cloud bot commented Feb 7, 2026

View your CI Pipeline Execution β†— for commit 717d5d8

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... βœ… Succeeded 4m 50s View β†—
nx run-many --target=build --exclude=examples/*... βœ… Succeeded 1s View β†—

☁️ Nx Cloud last updated this comment at 2026-02-07 06:52:04 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 7, 2026

More templates

@tanstack/angular-query-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-experimental@10102

@tanstack/eslint-plugin-query

npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@10102

@tanstack/query-async-storage-persister

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@10102

@tanstack/query-broadcast-client-experimental

npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@10102

@tanstack/query-core

npm i https://pkg.pr.new/@tanstack/query-core@10102

@tanstack/query-devtools

npm i https://pkg.pr.new/@tanstack/query-devtools@10102

@tanstack/query-persist-client-core

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@10102

@tanstack/query-sync-storage-persister

npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@10102

@tanstack/react-query

npm i https://pkg.pr.new/@tanstack/react-query@10102

@tanstack/react-query-devtools

npm i https://pkg.pr.new/@tanstack/react-query-devtools@10102

@tanstack/react-query-next-experimental

npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@10102

@tanstack/react-query-persist-client

npm i https://pkg.pr.new/@tanstack/react-query-persist-client@10102

@tanstack/solid-query

npm i https://pkg.pr.new/@tanstack/solid-query@10102

@tanstack/solid-query-devtools

npm i https://pkg.pr.new/@tanstack/solid-query-devtools@10102

@tanstack/solid-query-persist-client

npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@10102

@tanstack/svelte-query

npm i https://pkg.pr.new/@tanstack/svelte-query@10102

@tanstack/svelte-query-devtools

npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@10102

@tanstack/svelte-query-persist-client

npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@10102

@tanstack/vue-query

npm i https://pkg.pr.new/@tanstack/vue-query@10102

@tanstack/vue-query-devtools

npm i https://pkg.pr.new/@tanstack/vue-query-devtools@10102

commit: 717d5d8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant