Skip to content

Add test for cache write after error with errorPolicy: "all"#13280

Open
jerelmiller wants to merge 2 commits into
mainfrom
jerel/cache-write-after-error
Open

Add test for cache write after error with errorPolicy: "all"#13280
jerelmiller wants to merge 2 commits into
mainfrom
jerel/cache-write-after-error

Conversation

@jerelmiller

@jerelmiller jerelmiller commented Jun 17, 2026

Copy link
Copy Markdown
Member

Closes #13279

Add test demonstrating cache write after error with errorPolicy: "all".

Summary by CodeRabbit

  • Tests
    • Added test coverage for error handling behavior when partial GraphQL errors occur with data caching enabled, verifying correct state management and cache updates in this scenario.

@apollo-librarian

apollo-librarian Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: 358708a4496f0b666a2f5e08
Build Logs: View logs


✅ AI Style Review — No Changes Detected

No MDX files were changed in this pull request.

Review Log: View detailed log

This review is AI-generated. Please use common sense when accepting these suggestions, as they may not always be accurate or appropriate for your specific context.

@changeset-bot

changeset-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 3125bad

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

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: f7ed57c1-adfa-4e3e-9239-75d7374b0b24

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

A single test is added to the useQuery "Error handling" suite. It verifies that after a partial GraphQL response with errorPolicy: "all" and returnPartialData: true, a subsequent client.writeQuery targeting only a non-errored field causes a re-render with updated data, clears the error, and restores NetworkStatus.ready.

Changes

Regression test: errorPolicy "all" cache write reactivity

Layer / File(s) Summary
Regression test for cache write reactivity under errorPolicy: "all"
src/react/hooks/__tests__/useQuery.test.tsx
Adds an it(...) block that renders useQuery with errorPolicy: "all" and returnPartialData: true, confirms the initial partial-error state (goodField has data, badField is null), then calls client.writeQuery on the non-errored field and asserts the hook re-renders with the updated value, badField still null, and no error on the result.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Possibly related PRs

  • apollographql/apollo-client#13249: Adds tests for errorPolicy: "all" verifying NetworkStatus.ready is restored after field errors, closely related to the same error-handling behavior being tested here.

Poem

🐇 A field went bad, but good fields stayed,
The cache wrote on, un-blocked, unswayed.
errorPolicy: "all" said "let data through!"
Partial results and re-renders too.
The bunny hops past null fields with glee —
🌿 Cache updates flow now, wild and free!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change - adding a test for cache write behavior after error with errorPolicy: 'all', which directly relates to the changeset's focus on demonstrating this specific scenario.
Linked Issues check ✅ Passed The test directly validates the expected behavior described in issue #13279 by demonstrating cache writes work correctly after partial errors when using errorPolicy: 'all' and returnPartialData: true.
Out of Scope Changes check ✅ Passed The changes are entirely focused on adding a test case for the specific scenario described in the linked issue, with no unrelated modifications present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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


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.

❤️ Share

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

@jerelmiller jerelmiller force-pushed the jerel/cache-write-after-error branch from 8cafa85 to b7b42f8 Compare June 17, 2026 02:00
@pkg-pr-new

pkg-pr-new Bot commented Jun 17, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@apollo/client@13280

commit: 3125bad

jerelmiller added a commit that referenced this pull request Jun 30, 2026
…ue` in options (#13281)

Fixes #13280

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* `readQuery` and `readFragment` now correctly respect the `optimistic`
option provided in the options object, rather than defaulting to false.

* **Tests**
  * Added test coverage for optimistic read operations.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@jerelmiller jerelmiller reopened this Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cache updates silently dropped for queries with errorPolicy: 'all' when query is incomplete due to resolver error

1 participant