Skip to content

fix: tighten cache implementation constraints - #13268

Merged
DaleSeo merged 1 commit into
release-4.3from
fix/cache-implementation-constraints
Jun 10, 2026
Merged

fix: tighten cache implementation constraints#13268
DaleSeo merged 1 commit into
release-4.3from
fix/cache-implementation-constraints

Conversation

@DaleSeo

@DaleSeo DaleSeo commented Jun 10, 2026

Copy link
Copy Markdown
Member

As a quick follow-up to PR #13250, this fixes some cache override typing paths that still allowed ApolloCache, while the public mutation and refetch APIs now expect Cache.Implementation. Keeping these constraints aligned ensures that user-declared cache overrides work consistently through QueryInfo, internal refetch options, and deprecated React mutation aliases. We also regenerated the API reports so that the published type surface shows the corrected constraints.

Summary by CodeRabbit

  • Chores
    • Aligned cache-related type constraints across the library for consistency. TypeScript users working with custom cache implementations may notice updated type signatures in mutation helpers and query-related APIs.

@DaleSeo DaleSeo self-assigned this Jun 10, 2026
@changeset-bot

changeset-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 419e2b5

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

@apollo-librarian

apollo-librarian Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

✅ Docs preview ready

The preview is ready to be viewed. View the preview

File Changes

0 new, 3 changed, 0 removed
* graphos/routing/(latest)/header-propagation.mdx
* graphos/routing/(latest)/configuration/yaml.mdx
* graphos/routing/(latest)/security/cors.mdx

Build ID: fe99398cf5f6b14f91f73e18
Build Logs: View logs

URL: https://www.apollographql.com/docs/deploy-preview/fe99398cf5f6b14f91f73e18


✅ 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.

@coderabbitai

coderabbitai Bot commented Jun 10, 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: bbc7a8dc-fff9-4da7-91c4-e5f1f55a0699

📥 Commits

Reviewing files that changed from the base of the PR and between 9cd2f1d and 419e2b5.

📒 Files selected for processing (8)
  • .api-reports/api-report-core.api.md
  • .api-reports/api-report-react.api.md
  • .api-reports/api-report.api.md
  • .changeset/tidy-cache-type-constraints.md
  • .size-limits.json
  • src/core/QueryInfo.ts
  • src/core/types.ts
  • src/react/types/deprecated.ts

📝 Walkthrough

Walkthrough

This PR systematically migrates generic TCache type constraints from ApolloCache to Cache.Implementation across core query types, React deprecated mutation helpers, and their API reports, aligning the library's exported type surface with the overridable cache interface.

Changes

Cache Type Constraint Unification

Layer / File(s) Summary
Core type constraints migration
src/core/types.ts, src/core/QueryInfo.ts, .api-reports/api-report-core.api.md, .api-reports/api-report.api.md
InternalRefetchQueriesOptions and QueryInfo update their TCache generic bounds from ApolloCache to Cache.Implementation, with imports switched to Cache from @apollo/client/cache. Generated API reports reflect the signature changes.
React deprecated mutation types constraint migration
src/react/types/deprecated.ts, .api-reports/api-report-react.api.md
Deprecated mutation helper types (MutationHookOptions, MutationFunctionOptions, MutationTuple) update their TCache constraints and defaults from ApolloCache to Cache.Implementation, with imports adjusted accordingly. API report is regenerated to match.
Changeset documentation and size limits
.changeset/tidy-cache-type-constraints.md, .size-limits.json
Changeset documents the alignment of remaining cache generic constraints with Cache.Implementation. Bundle size limits are updated for four Apollo Client import variants.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • apollographql/apollo-client#13250: Both PRs refactor the same exported/public typings to swap ApolloCache-based TCache constraints/defaults over to Cache.Implementation (including refetch/mutate and React mutation-related generic types), aligning cache typing with the new overridable TypeOverrides.cache mechanism.

Suggested reviewers

  • jerelmiller
  • phryneas
  • pragl

Poem

🐰 From Apollo's cache, a tidy refrain,
Type constraints now unified, crystal and plain,
Cache.Implementation rings out so true,
Generic bounds lessoned—the old ApolloCache too,
Mutations and queries aligned in the chase! 🌙✨

🚥 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 'fix: tighten cache implementation constraints' is fully related to the main change in the changeset, which updates TypeScript generic type constraints from ApolloCache to Cache.Implementation across multiple files for consistency.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

src/core/QueryInfo.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

src/core/types.ts

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

src/react/types/deprecated.ts

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.


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.

@DaleSeo
DaleSeo force-pushed the fix/cache-implementation-constraints branch from 76dd62f to 4ac68c7 Compare June 10, 2026 15:14
@pkg-pr-new

pkg-pr-new Bot commented Jun 10, 2026

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

commit: 419e2b5

@jerelmiller jerelmiller left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could have sworn I updated these. I remember doing so, but I must have git reset --hard by accident or something 🤔. Anyways, thanks for getting the rest!

@github-actions github-actions Bot added the auto-cleanup 🤖 label Jun 10, 2026
@DaleSeo
DaleSeo force-pushed the fix/cache-implementation-constraints branch from 4ac68c7 to 2e2baf1 Compare June 10, 2026 15:52
@DaleSeo
DaleSeo force-pushed the fix/cache-implementation-constraints branch from fc43c27 to 419e2b5 Compare June 10, 2026 17:00
@DaleSeo
DaleSeo marked this pull request as ready for review June 10, 2026 17:03
@DaleSeo
DaleSeo merged commit 2f0ab7f into release-4.3 Jun 10, 2026
47 checks passed
@jerelmiller
jerelmiller deleted the fix/cache-implementation-constraints branch June 11, 2026 01:52
jerelmiller pushed a commit that referenced this pull request Jun 11, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to release-4.3, this
PR will be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`release-4.3` is currently in **pre mode** so this branch has
prereleases rather than normal releases. If you want to exit
prereleases, run `changeset pre exit` on `release-4.3`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases
## @apollo/client@4.3.0-alpha.1

### Patch Changes

- [#13268](#13268)
[`419e2b5`](419e2b5)
Thanks [@DaleSeo](https://github.com/DaleSeo)! - Align the remaining
cache generic constraints with `Cache.Implementation`. The deprecated
React mutation types (`MutationHookOptions`, `MutationFunctionOptions`,
`MutationTuple`) and the internal `InternalRefetchQueriesOptions` and
`QueryInfo` types still constrained their cache type parameter to
`ApolloCache`, so they now match the rest of the overridable cache API.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants