Skip to content

🤖🤖🤖 Fix readFragment optimistic option#13278

Closed
cyphercodes wants to merge 1 commit into
apollographql:mainfrom
cyphercodes:cyphercodes/fix-readfragment-optimistic
Closed

🤖🤖🤖 Fix readFragment optimistic option#13278
cyphercodes wants to merge 1 commit into
apollographql:mainfrom
cyphercodes:cyphercodes/fix-readfragment-optimistic

Conversation

@cyphercodes

@cyphercodes cyphercodes commented Jun 13, 2026

Copy link
Copy Markdown

Fixes #13276

Summary

  • Default ApolloClient.readFragment's positional optimistic argument to options.optimistic.
  • Add a regression test for optimistic fragment reads via the options object.
  • Add a changeset for the patch release note.

Testing

  • npm run test -- --runInBand --testRegex src/core/__tests__/client.readFragment/general.test.ts
  • git diff --check
  • npx prettier --check src/core/ApolloClient.ts src/core/__tests__/client.readFragment/general.test.ts .changeset/fresh-birds-read.md
  • npm run changeset-check

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • ApolloClient.readFragment now respects the optimistic option supplied in the options object.
  • Tests

    • Added test coverage validating readFragment honors the optimistic option.

@apollo-cla

Copy link
Copy Markdown

@cyphercodes: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

@apollo-librarian

apollo-librarian Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

✅ 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 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f1bc2d1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@apollo/client Patch

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

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: 9616b1ae-f975-41fc-8fc6-d3334215e31f

📥 Commits

Reviewing files that changed from the base of the PR and between b9ab334 and f1bc2d1.

📒 Files selected for processing (3)
  • .changeset/fresh-birds-read.md
  • src/core/ApolloClient.ts
  • src/core/__tests__/client.readFragment/general.test.ts

📝 Walkthrough

Walkthrough

This PR fixes ApolloClient.readFragment to respect the optimistic option in the options object. The method's second parameter now defaults to !!options.optimistic instead of false, enabling the modern API to work correctly without requiring the deprecated second argument.

Changes

readFragment optimistic option fix

Layer / File(s) Summary
Implementation fix and test validation
src/core/ApolloClient.ts, src/core/__tests__/client.readFragment/general.test.ts, .changeset/fresh-birds-read.md
The readFragment method's optimistic parameter default changes from false to !!options.optimistic, allowing readFragment({ optimistic: true }) to return optimistic cache data. A new test validates both default (base) and optimistic paths, and a changeset documents the patch-level fix.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A fragment once ignored the truth,
Its optimistic cache left uncouth,
But now when asked with truthful care,
It reads the wishes floating fair! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title includes decorative emoji and uses vague phrasing that doesn't clearly convey the specific change in context of the codebase. Consider using a clearer title without emoji, such as 'Fix ApolloClient.readFragment to respect optimistic option in options object'.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The pull request successfully implements all coding requirements from issue #13276: changes the default value of the optimistic parameter to respect options.optimistic, adds regression tests, and includes the changeset entry.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the readFragment optimistic option handling as specified in issue #13276; no out-of-scope changes are 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.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed due to a network error.


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

Copy link
Copy Markdown
Member

Hey @cyphercodes 👋

Can you sign the CLA before we can do anything with this PR? I opened #13281 without realizing you had this PR open so I want to make sure I give you credit for your contribution, but I'll need you to sign the CLA before I can do so. Thanks!

@jerelmiller

jerelmiller commented Jun 29, 2026

Copy link
Copy Markdown
Member

Superseded by #13281

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.

client.readFragment incorrectly handles optimistic option

3 participants