Skip to content

Silence warnings that should be muted#13168

Merged
jerelmiller merged 14 commits intoversion-3.xfrom
jerel/fix-warnings
Mar 12, 2026
Merged

Silence warnings that should be muted#13168
jerelmiller merged 14 commits intoversion-3.xfrom
jerel/fix-warnings

Conversation

@jerelmiller
Copy link
Copy Markdown
Member

@jerelmiller jerelmiller commented Mar 5, 2026

Fixes #13149
Fixes #12917
Fixes #13057

Fixes issues where some deprecation warnings from React hooks were not properly muted even when muted globally. Also fixes some issues where rogue deprecation warnings were emitted even when the internal implementation muted them. This was due to a bundling issue where a copy of the slot was created in each entrypoint since we imported from the file directly.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed deprecation warnings appearing across multiple entry points—muting a deprecation from one entry point now correctly suppresses warnings everywhere.
    • Fixed deprecation warnings in React hooks not being properly silenced when globally disabled.
  • New Features

    • Deprecation management utilities are now available from the main utilities module for centralized access and control.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 5, 2026

🦋 Changeset detected

Latest commit: 0a12305

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
Copy link
Copy Markdown

coderabbitai bot commented Mar 5, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (1)
  • release-*

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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 789b87df-f159-45e8-b6ec-98de55a38a1e

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

This pull request refactors Apollo Client's deprecation warning system to ensure that muting deprecations from any entrypoint suppresses warnings globally across all entrypoints. It introduces new public utilities (muteDeprecations, warnDeprecated, warnRemovedOption with enhanced type safety), consolidates deprecation exports through the main utilities barrel, and updates hooks and tests to use the new centralized deprecation handling.

Changes

Cohort / File(s) Summary
API Report Updates
.api-reports/api-report-cache.api.md, .api-reports/api-report-react_internal.api.md
Diagnostic comment line shifts reflecting updated export locations; no functional changes to public API.
Deprecation Utilities API
.api-reports/api-report-utilities.api.md
Introduces new public types (DeprecationName, PossibleDeprecations, WithValueArgs) and functions (muteDeprecations, warnDeprecated, warnRemovedOption) for centralized deprecation handling with enhanced type safety.
Changelog Entries
.changeset/calm-kangaroos-tie.md, .changeset/two-rings-work.md
Documents patch fixes for deprecation warning suppression across entrypoints and React hooks.
Import Path Consolidation
src/cache/core/cache.ts, src/cache/inmemory/inMemoryCache.ts, src/core/ApolloClient.ts, src/core/ObservableQuery.ts, src/core/QueryInfo.ts, src/core/QueryManager.ts, src/link/core/ApolloLink.ts, src/react/hoc/graphql.tsx, src/react/hoc/mutation-hoc.tsx, src/react/hoc/query-hoc.tsx, src/react/hoc/subscription-hoc.tsx, src/react/hooks/useBackgroundQuery.ts, src/react/hooks/useFragment.ts, src/react/hooks/useLazyQuery.ts, src/react/hooks/useLoadableQuery.ts, src/react/hooks/useSuspenseQuery.ts, src/react/internal/cache/QueryReference.ts, src/react/parser/index.ts, src/react/query-preloader/createQueryPreloader.ts, src/testing/react/MockedProvider.tsx
Updated import paths from utilities/deprecation/index.js to utilities/index.js, centralizing deprecation utilities through the main barrel export.
Hook Signature Updates
src/react/hooks/internal/useWarnRemovedOption.ts
Enhanced useWarnRemovedOption with generic CallSite type parameter and stricter type constraints; replaces primitive warning logic with centralized warnRemovedOption call guarded by __DEV__.
useQuery Deprecation Muting
src/react/hooks/useQuery.ts
Updated muteDeprecations call to mute both canonizeResults and partialRefetch deprecations (previously only canonizeResults).
Hook Utility Updates
src/react/hooks/internal/useWarnRemoved.ts
Updated import paths for DeprecationName and warnDeprecated to centralized utilities module.
Testing Utilities
src/testing/internal/disposables/withMutedDeprecations.ts, src/testing/internal/disposables/index.ts
Introduces new withMutedDeprecations function that saves/restores global deprecation mute state; re-exported from main testing disposables index.
Deprecation Module Updates
src/utilities/deprecation/index.ts
Removed exported withDisabledDeprecations helper function.
Utilities Barrel Export
src/utilities/index.ts
Added re-exports of muteDeprecations, warnRemovedOption, warnDeprecated, DeprecationName, and PossibleDeprecations from deprecation module.
Test Utilities Migration
src/core/__tests__/ObservableQuery.ts, src/testing/react/__tests__/MockedProvider.test.tsx
Replaced withDisabledDeprecations with withMutedDeprecations in test files; updated imports from testing/internal.
useQuery Test Coverage
src/react/hooks/__tests__/useQuery.test.tsx
Added new deprecations test suite verifying that no console warnings are emitted when deprecated options are globally muted; added imports for createClientWrapper and withMutedDeprecations.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Test Environment
    participant Hook as useQuery Hook
    participant DepSys as Deprecation System
    participant GlobalState as Global State<br/>(apollo.deprecations)
    participant Console as Console.warn

    Test->>DepSys: withMutedDeprecations(callback)
    DepSys->>GlobalState: Save current mute state
    DepSys->>GlobalState: Set mute flag to true
    DepSys->>Test: Execute callback within muted context
    
    Test->>Hook: Render with deprecated option<br/>(e.g., onError)
    Hook->>DepSys: Check if deprecation muted?
    DepSys->>GlobalState: Read mute flag
    GlobalState-->>DepSys: Mute flag = true
    DepSys->>Hook: Return muted state
    Hook->>Console: Skip warning (muted)
    
    Hook-->>Test: Component renders without warning
    Test->>DepSys: Cleanup/dispose
    DepSys->>GlobalState: Restore previous mute state
    DepSys-->>Test: Context cleaned up
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Silence warnings that should be muted' accurately reflects the main objective: fixing the deprecation-muting mechanism to reliably suppress warnings across entrypoints and test environments.
Linked Issues check ✅ Passed The PR successfully addresses all three linked issues: #13149 (global suppression not working for hook options), #12917 (false-positive deprecation warnings in tests), and #13057 (getDiff causing canonizeResults warnings).
Out of Scope Changes check ✅ Passed All code changes are directly related to fixing the deprecation-muting mechanism. Changes include: reorganizing exports to prevent bundling issues, updating imports across the codebase, adding test helpers, and implementing proper type-safe deprecation handling.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jerel/fix-warnings
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Tip

CodeRabbit can generate a title for your PR based on the changes.

Add @coderabbitai placeholder anywhere in the title of your PR and CodeRabbit will replace it with a title based on the changes in the PR. You can change the placeholder by changing the reviews.auto_title_placeholder setting.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 5, 2026

npm i https://pkg.pr.new/@apollo/client@13168

commit: 4143f5f

muteDeprecations,
warnRemovedOption,
} from "../../utilities/deprecation/index.js";
import { muteDeprecations, warnRemovedOption } from "../../utilities/index.js";
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Turns out we had a bundling issue where we had copies of the slot in each entrypoint that imported from utilities/deprecation/index.js, so in some cases the warning would be emitted even though it was muted. Moving the imports to the utilities entrypoint fixes this issue.

See the diff in the build output where you'll notice that several entrypoints no longer have separate copies of the slot used to mute warnings: https://github.com/apollographql/apollo-client/actions/runs/22732448938

const didWarn = React.useRef(false);

if (name in options && !didWarn.current) {
invariant.warn(
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Major facepalm moment discovering this 🤦‍♂️

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses deprecation-warning suppression inconsistencies across Apollo Client entrypoints by routing deprecation utilities through a shared utilities barrel export and updating internal imports to avoid duplicated module state during bundling.

Changes:

  • Re-export muteDeprecations/warnDeprecated/warnRemovedOption (and related types) from src/utilities/index.ts and update internal imports to use that shared entrypoint.
  • Replace test-only global deprecation muting helper with a new disposable withMutedDeprecations.
  • Add/adjust React hook test coverage to ensure deprecated hook options don’t warn when global deprecations are muted.

Reviewed changes

Copilot reviewed 36 out of 36 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/utilities/index.ts Re-export deprecation helpers/types via utilities barrel.
src/utilities/deprecation/index.ts Remove withDisabledDeprecations helper.
src/testing/react/tests/MockedProvider.test.tsx Switch tests to withMutedDeprecations.
src/testing/react/MockedProvider.tsx Import deprecation helpers from utilities/index.
src/testing/internal/disposables/withMutedDeprecations.ts New disposable to globally mute deprecations in tests.
src/testing/internal/disposables/index.ts Export withMutedDeprecations.
src/react/query-preloader/createQueryPreloader.ts Import deprecation helpers from utilities/index.
src/react/parser/index.ts Import deprecation helpers from utilities/index.
src/react/internal/cache/QueryReference.ts Import muteDeprecations from utilities/index.
src/react/hooks/useSuspenseQuery.ts Import muteDeprecations from utilities/index.
src/react/hooks/useQuery.ts Import muteDeprecations from utilities/index; mute additional option.
src/react/hooks/useLoadableQuery.ts Import muteDeprecations from utilities/index.
src/react/hooks/useLazyQuery.ts Import warnRemovedOption from utilities/index.
src/react/hooks/useFragment.ts Import muteDeprecations from utilities/index.
src/react/hooks/useBackgroundQuery.ts Import muteDeprecations from utilities/index.
src/react/hooks/internal/useWarnRemovedOption.ts Refactor to use warnRemovedOption and stronger typing.
src/react/hooks/internal/useWarnRemoved.ts Import deprecation types/helpers from utilities/index.
src/react/hooks/tests/useQuery.test.tsx Add test ensuring global muting suppresses hook option warnings.
src/react/hoc/subscription-hoc.tsx Import deprecation helpers from utilities/index.
src/react/hoc/query-hoc.tsx Import deprecation helpers from utilities/index.
src/react/hoc/mutation-hoc.tsx Import deprecation helpers from utilities/index.
src/react/hoc/graphql.tsx Import deprecation helpers from utilities/index.
src/link/core/ApolloLink.ts Import warnDeprecated from utilities/index.
src/core/tests/ObservableQuery.ts Switch tests to withMutedDeprecations disposable.
src/core/QueryManager.ts Import muteDeprecations from utilities/index.
src/core/QueryInfo.ts Import muteDeprecations from utilities/index.
src/core/ObservableQuery.ts Import deprecation helpers from utilities/index.
src/core/ApolloClient.ts Import warnRemovedOption from utilities/index.
src/cache/inmemory/inMemoryCache.ts Import deprecation helpers from utilities/index.
src/cache/core/cache.ts Import deprecation helpers from utilities/index.
src/tests/snapshots/exports.ts.snap Update utilities export snapshot for new exports.
.changeset/two-rings-work.md Changeset for hook deprecation muting fix.
.changeset/calm-kangaroos-tie.md Changeset for entrypoint-slot duplication fix.
.api-reports/api-report-utilities.api.md API report updates; includes new warning about missing export.
.api-reports/api-report-react_internal.api.md API report line-number update.
.api-reports/api-report-cache.api.md API report line-number update.

@jerelmiller
Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 6, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/core/__tests__/ObservableQuery.ts (1)

34-34: Import muteDeprecations from the shared utilities barrel here.

This test still reaches into ../../utilities/deprecation, so it no longer exercises the same entrypoint path the rest of the PR is standardizing on. Pulling it from ../../utilities keeps the test aligned with the shared module graph that avoids duplicated deprecation state.

Suggested diff
-import { muteDeprecations } from "../../utilities/deprecation";
+import { muteDeprecations } from "../../utilities";
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/core/__tests__/ObservableQuery.ts` at line 34, Replace the direct import
of muteDeprecations from the utilities/deprecation module with the shared
utilities barrel import so the test uses the same entrypoint as the rest of the
PR; specifically update the import that references muteDeprecations in
ObservableQuery tests to import muteDeprecations from "../../utilities" (leave
the symbol name muteDeprecations unchanged) so the test exercises the shared
module graph and avoids duplicated deprecation state.
src/react/hooks/__tests__/useQuery.test.tsx (1)

34-39: Use the internal entrypoint alias here.

This new import reaches into ../../../testing/internal directly. The repo guideline asks internal APIs to be consumed through the @apollo/client/*/internal entrypoints instead of relative source paths.

As per coding guidelines, "Use @apollo/client/*/internal paths for accessing internal APIs".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/react/hooks/__tests__/useQuery.test.tsx` around lines 34 - 39, Replace
the direct relative import of internal test helpers with the package internal
entrypoint: change the import source for createClientWrapper,
setupPaginatedCase, spyOnConsole, and withMutedDeprecations so they are imported
from the appropriate `@apollo/client/`*/internal testing entrypoint (use the
react/testing internal alias used elsewhere in the repo) instead of
"../../../testing/internal"; keep the named imports unchanged so the symbols
(createClientWrapper, setupPaginatedCase, spyOnConsole, withMutedDeprecations)
continue to be referenced the same way.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.api-reports/api-report-utilities.api.md:
- Around line 1984-1987: The public function muteDeprecations currently
references the type WithValueArgs without exporting it; either export
WithValueArgs from the utilities entrypoint (add WithValueArgs to the public
type exports) so the type is visible to consumers, or remove the external
dependency by inlining the tuple/type directly in the muteDeprecations
signature; update the utilities index export list to include WithValueArgs or
modify the muteDeprecations declaration to use an inline tuple type to resolve
the ae-forgotten-export warning.

In `@src/react/hooks/internal/useWarnRemovedOption.ts`:
- Around line 18-24: The one-shot flag didWarn.current is being set before
confirming the deprecated option is present, so change useWarnRemovedOption to
only call warnRemovedOption and set didWarn.current when the deprecated key
actually exists (guard with "name in options" or options.hasOwnProperty(name));
if you also need muted deprecations to be transparent, adjust warnRemovedOption
(the function) to return a boolean indicating whether it emitted a warning and
only set didWarn.current when that returns true.

---

Nitpick comments:
In `@src/core/__tests__/ObservableQuery.ts`:
- Line 34: Replace the direct import of muteDeprecations from the
utilities/deprecation module with the shared utilities barrel import so the test
uses the same entrypoint as the rest of the PR; specifically update the import
that references muteDeprecations in ObservableQuery tests to import
muteDeprecations from "../../utilities" (leave the symbol name muteDeprecations
unchanged) so the test exercises the shared module graph and avoids duplicated
deprecation state.

In `@src/react/hooks/__tests__/useQuery.test.tsx`:
- Around line 34-39: Replace the direct relative import of internal test helpers
with the package internal entrypoint: change the import source for
createClientWrapper, setupPaginatedCase, spyOnConsole, and withMutedDeprecations
so they are imported from the appropriate `@apollo/client/`*/internal testing
entrypoint (use the react/testing internal alias used elsewhere in the repo)
instead of "../../../testing/internal"; keep the named imports unchanged so the
symbols (createClientWrapper, setupPaginatedCase, spyOnConsole,
withMutedDeprecations) continue to be referenced the same way.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d02a5b51-7e9f-404d-8a9d-f35802786b6a

📥 Commits

Reviewing files that changed from the base of the PR and between e0301a8 and 5d2ecd6.

⛔ Files ignored due to path filters (1)
  • src/__tests__/__snapshots__/exports.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (35)
  • .api-reports/api-report-cache.api.md
  • .api-reports/api-report-react_internal.api.md
  • .api-reports/api-report-utilities.api.md
  • .changeset/calm-kangaroos-tie.md
  • .changeset/two-rings-work.md
  • src/cache/core/cache.ts
  • src/cache/inmemory/inMemoryCache.ts
  • src/core/ApolloClient.ts
  • src/core/ObservableQuery.ts
  • src/core/QueryInfo.ts
  • src/core/QueryManager.ts
  • src/core/__tests__/ObservableQuery.ts
  • src/link/core/ApolloLink.ts
  • src/react/hoc/graphql.tsx
  • src/react/hoc/mutation-hoc.tsx
  • src/react/hoc/query-hoc.tsx
  • src/react/hoc/subscription-hoc.tsx
  • src/react/hooks/__tests__/useQuery.test.tsx
  • src/react/hooks/internal/useWarnRemoved.ts
  • src/react/hooks/internal/useWarnRemovedOption.ts
  • src/react/hooks/useBackgroundQuery.ts
  • src/react/hooks/useFragment.ts
  • src/react/hooks/useLazyQuery.ts
  • src/react/hooks/useLoadableQuery.ts
  • src/react/hooks/useQuery.ts
  • src/react/hooks/useSuspenseQuery.ts
  • src/react/internal/cache/QueryReference.ts
  • src/react/parser/index.ts
  • src/react/query-preloader/createQueryPreloader.ts
  • src/testing/internal/disposables/index.ts
  • src/testing/internal/disposables/withMutedDeprecations.ts
  • src/testing/react/MockedProvider.tsx
  • src/testing/react/__tests__/MockedProvider.test.tsx
  • src/utilities/deprecation/index.ts
  • src/utilities/index.ts
💤 Files with no reviewable changes (1)
  • src/utilities/deprecation/index.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js,jsx}: Use @apollo/client/*/internal paths for accessing internal APIs
Use RxJS observables for reactive programming patterns
Follow existing code style enforced by ESLint and Prettier

Files:

  • src/cache/inmemory/inMemoryCache.ts
  • src/react/hooks/useSuspenseQuery.ts
  • src/testing/react/MockedProvider.tsx
  • src/react/internal/cache/QueryReference.ts
  • src/react/hooks/useLoadableQuery.ts
  • src/link/core/ApolloLink.ts
  • src/utilities/index.ts
  • src/react/hoc/query-hoc.tsx
  • src/testing/internal/disposables/index.ts
  • src/core/__tests__/ObservableQuery.ts
  • src/core/ApolloClient.ts
  • src/react/hooks/__tests__/useQuery.test.tsx
  • src/react/hooks/useFragment.ts
  • src/react/hoc/graphql.tsx
  • src/react/hooks/useLazyQuery.ts
  • src/react/hooks/useQuery.ts
  • src/react/hoc/subscription-hoc.tsx
  • src/core/QueryInfo.ts
  • src/react/hoc/mutation-hoc.tsx
  • src/core/ObservableQuery.ts
  • src/react/hooks/internal/useWarnRemovedOption.ts
  • src/core/QueryManager.ts
  • src/react/query-preloader/createQueryPreloader.ts
  • src/cache/core/cache.ts
  • src/react/parser/index.ts
  • src/react/hooks/useBackgroundQuery.ts
  • src/testing/internal/disposables/withMutedDeprecations.ts
  • src/react/hooks/internal/useWarnRemoved.ts
  • src/testing/react/__tests__/MockedProvider.test.tsx
**/index.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

All public exports should go through index files

Files:

  • src/utilities/index.ts
  • src/testing/internal/disposables/index.ts
  • src/react/parser/index.ts
🧠 Learnings (7)
📚 Learning: 2026-02-19T17:01:54.257Z
Learnt from: CR
Repo: apollographql/apollo-client PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-02-19T17:01:54.257Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use `apollo/client/*/internal` paths for accessing internal APIs

Applied to files:

  • .changeset/calm-kangaroos-tie.md
  • src/react/hooks/useSuspenseQuery.ts
  • src/testing/react/MockedProvider.tsx
  • src/react/internal/cache/QueryReference.ts
  • src/link/core/ApolloLink.ts
  • src/react/hoc/query-hoc.tsx
  • src/core/ApolloClient.ts
  • src/react/hooks/__tests__/useQuery.test.tsx
  • src/react/hoc/graphql.tsx
  • src/react/hooks/useLazyQuery.ts
  • src/react/hooks/useQuery.ts
  • .api-reports/api-report-react_internal.api.md
  • src/core/QueryInfo.ts
  • src/react/hoc/mutation-hoc.tsx
  • src/react/parser/index.ts
  • .changeset/two-rings-work.md
  • src/react/hooks/internal/useWarnRemoved.ts
  • .api-reports/api-report-utilities.api.md
📚 Learning: 2026-02-24T10:19:44.627Z
Learnt from: phryneas
Repo: apollographql/apollo-client PR: 13132
File: integration-tests/type-tests/package.json:1-16
Timestamp: 2026-02-24T10:19:44.627Z
Learning: In integration-tests/type-tests/package.json, the apollo/client version is intentionally not kept in sync with the root package version because it gets overwritten during CI execution. Version mismatches in this file should not be flagged as issues.

Applied to files:

  • .changeset/calm-kangaroos-tie.md
  • src/core/ApolloClient.ts
  • src/react/hooks/__tests__/useQuery.test.tsx
  • src/cache/core/cache.ts
  • .changeset/two-rings-work.md
📚 Learning: 2026-02-19T17:01:54.257Z
Learnt from: CR
Repo: apollographql/apollo-client PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-02-19T17:01:54.257Z
Learning: Testing utilities should be located in `src/testing/` with core testing utilities in `core/` subdirectory and React testing utilities (MockedProvider) in `react/` subdirectory

Applied to files:

  • src/testing/react/MockedProvider.tsx
  • src/react/hooks/__tests__/useQuery.test.tsx
  • src/testing/react/__tests__/MockedProvider.test.tsx
📚 Learning: 2026-02-19T17:01:54.257Z
Learnt from: CR
Repo: apollographql/apollo-client PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-02-19T17:01:54.257Z
Learning: Applies to **/index.{ts,tsx,js,jsx} : All public exports should go through index files

Applied to files:

  • src/utilities/index.ts
  • .api-reports/api-report-react_internal.api.md
📚 Learning: 2026-02-19T17:01:54.257Z
Learnt from: CR
Repo: apollographql/apollo-client PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-02-19T17:01:54.257Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use RxJS observables for reactive programming patterns

Applied to files:

  • src/core/__tests__/ObservableQuery.ts
  • src/react/hoc/subscription-hoc.tsx
  • src/core/ObservableQuery.ts
📚 Learning: 2026-02-19T17:01:54.257Z
Learnt from: CR
Repo: apollographql/apollo-client PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-02-19T17:01:54.257Z
Learning: Core Apollo Client implementation should be located in `src/core/` with key files including `ApolloClient.ts`, `ObservableQuery.ts`, and `QueryManager.ts`

Applied to files:

  • src/core/ApolloClient.ts
  • src/react/hooks/__tests__/useQuery.test.tsx
  • .api-reports/api-report-react_internal.api.md
  • src/core/QueryInfo.ts
  • src/testing/react/__tests__/MockedProvider.test.tsx
📚 Learning: 2026-02-19T17:01:54.257Z
Learnt from: CR
Repo: apollographql/apollo-client PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-02-19T17:01:54.257Z
Learning: All changes require a changeset created using `npx changeset`

Applied to files:

  • .changeset/two-rings-work.md
🔇 Additional comments (23)
.api-reports/api-report-cache.api.md (1)

1185-1185: LGTM!

This is an auto-generated API report file. The only change is a line number shift in the warning comment, reflecting source file reorganization with no API surface changes.

src/react/hoc/subscription-hoc.tsx (1)

17-17: LGTM!

Import path correctly updated to use the centralized utilities barrel, aligning with the PR objective to ensure consistent deprecation-muting across entrypoints.

src/utilities/index.ts (1)

152-161: LGTM!

The deprecation utilities are correctly re-exported from the central utilities barrel with proper separation of value exports and type exports. This is the key change that enables consistent deprecation-muting across all entrypoints, fixing the bundling issue described in the PR objectives. As per coding guidelines, all public exports going through index files.

src/react/internal/cache/QueryReference.ts (1)

21-21: LGTM!

Import path correctly updated to use the centralized utilities barrel for muteDeprecations.

src/cache/inmemory/inMemoryCache.ts (1)

37-37: LGTM!

Import path correctly updated to use the centralized utilities barrel for muteDeprecations and warnRemovedOption. All usages throughout the file remain unchanged and properly handle the deprecated cache options.

src/react/hoc/mutation-hoc.tsx (1)

19-19: LGTM!

Import path correctly updated to use the centralized utilities barrel.

src/react/hoc/query-hoc.tsx (1)

18-18: LGTM!

Import path correctly updated to use the centralized utilities barrel.

src/react/hooks/useLazyQuery.ts (1)

32-32: LGTM!

Import path correctly updated to use the centralized utilities barrel for warnRemovedOption.

src/react/parser/index.ts (1)

15-15: LGTM!

The import path update aligns with the PR's goal of centralizing deprecation utilities through the main utilities barrel. This ensures that muting deprecations works consistently across all entrypoints.

src/testing/react/MockedProvider.tsx (1)

13-13: LGTM!

The import path update correctly centralizes deprecation utility imports through the main utilities barrel, ensuring consistent deprecation muting behavior in the MockedProvider testing utility.

src/react/hooks/useBackgroundQuery.ts (1)

25-25: LGTM!

The import path update aligns with the centralized deprecation utilities approach. This ensures the canonizeResults deprecation muting at line 240 works consistently across entrypoints.

.changeset/calm-kangaroos-tie.md (1)

1-5: LGTM!

The changeset accurately describes the bug fix for deprecation muting across entrypoints. A patch version bump is appropriate for this fix.

src/react/hoc/graphql.tsx (1)

11-11: LGTM!

The import path update correctly centralizes deprecation utility imports, ensuring consistent behavior for the deprecated graphql HOC and its internal deprecation muting.

src/core/ObservableQuery.ts (1)

45-49: LGTM!

The import path update correctly centralizes deprecation utility imports through the main utilities barrel. This ensures deprecation muting works consistently for ObservableQuery's deprecated methods (result, getLastResult, getLastError, resetLastResults, setOptions).

src/core/ApolloClient.ts (1)

297-297: LGTM!

The import path update correctly centralizes warnRemovedOption through the main utilities barrel, ensuring consistent deprecation warning behavior across ApolloClient's deprecated options.

src/core/QueryInfo.ts (1)

19-19: LGTM!

The import path update correctly centralizes muteDeprecations through the main utilities barrel. This fix directly addresses issue #13057, ensuring that internal calls to cache.diff with canonizeResults and observableQuery.getLastError() properly suppress deprecation warnings when muting is enabled.

src/testing/internal/disposables/index.ts (1)

5-5: Good barrel export.

Re-exporting withMutedDeprecations here keeps the disposable test helpers discoverable through the index instead of another deep import.

As per coding guidelines, "All public exports should go through index files".

src/testing/react/__tests__/MockedProvider.test.tsx (1)

875-875: Nice isolation around the warning-count assertions.

Scoping withMutedDeprecations() to these tests keeps the expectations focused on MockLink warnings instead of unrelated deprecation noise.

Also applies to: 921-921, 964-964

src/testing/internal/disposables/withMutedDeprecations.ts (1)

7-13: Scoped restore looks right.

Saving the previous global flag and restoring it through withCleanup makes the muting helper deterministic for nested test scopes.

src/react/hooks/useQuery.ts (1)

217-226: Scoped muting is in the right place.

Wrapping client.watchQuery with both deprecation names fixes the internal warning path without masking the hook-level warnings emitted earlier in useQuery_.

src/core/__tests__/ObservableQuery.ts (1)

1834-1834: Good test hardening.

Using withMutedDeprecations() here keeps the warning assertion targeted at the refetch({ variables }) message instead of unrelated deprecation output.

.api-reports/api-report-react_internal.api.md (1)

2651-2652: LGTM - Expected auto-generated API report update.

These are diagnostic comment position updates in the auto-generated API Extractor report. The relocation of these warning notes is expected when refactoring imports and exports elsewhere in the codebase, as described in the PR objectives.

src/react/hooks/__tests__/useQuery.test.tsx (1)

13617-13647: No action required; test is correctly anchored to the global suppression slot.

The test properly exercises the regression path for issue #13149. Both withMutedDeprecations() and the runtime deprecation utilities use the same global slot (Symbol.for("apollo.deprecations")), so the test will catch any future breaks to the global suppression mechanism.

Comment on lines +1984 to +1987
// Warning: (ae-forgotten-export) The symbol "WithValueArgs" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export function muteDeprecations<TResult, TArgs extends any[], TThis = any>(name: DeprecationName | DeprecationName[], ...args: WithValueArgs<TResult, TArgs, TThis>): TResult;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's understand the repository structure
git ls-files | grep -E '\.(api\.md|d\.ts|ts)$' | head -20

Repository: apollographql/apollo-client

Length of output: 919


🏁 Script executed:

# Search for WithValueArgs definition
rg 'WithValueArgs' --type ts --type tsx -A 2 -B 2

Repository: apollographql/apollo-client

Length of output: 98


🏁 Script executed:

# Find the entrypoint (index.d.ts)
fd 'index\.d\.ts' --type f

Repository: apollographql/apollo-client

Length of output: 102


🏁 Script executed:

# Search for WithValueArgs with correct type
rg 'WithValueArgs' --type ts -A 2 -B 2

Repository: apollographql/apollo-client

Length of output: 846


🏁 Script executed:

# Find the utilities entry point
fd 'index' src/utilities --type f

Repository: apollographql/apollo-client

Length of output: 319


🏁 Script executed:

# Read the API report file at the specified lines
head -2000 .api-reports/api-report-utilities.api.md | tail -100

Repository: apollographql/apollo-client

Length of output: 4432


🏁 Script executed:

# Check what's exported from utilities index
cat src/utilities/index.ts

Repository: apollographql/apollo-client

Length of output: 4517


🏁 Script executed:

# Check if muteDeprecations is exported from the utilities entrypoint
rg 'muteDeprecations' src/utilities/index.ts

Repository: apollographql/apollo-client

Length of output: 90


🏁 Script executed:

# Check the deprecation module for all exports
cat src/utilities/deprecation/index.ts

Repository: apollographql/apollo-client

Length of output: 3668


Export WithValueArgs from the utilities entrypoint to resolve the API Extractor warning.

The muteDeprecations function signature exposes WithValueArgs as a public type, but WithValueArgs is not exported from the utilities entry point, triggering an ae-forgotten-export warning. Add WithValueArgs to the type exports from src/utilities/deprecation/index.ts in src/utilities/index.ts, or alternatively inline the tuple type directly in the muteDeprecations signature to eliminate the need for a public type export.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.api-reports/api-report-utilities.api.md around lines 1984 - 1987, The
public function muteDeprecations currently references the type WithValueArgs
without exporting it; either export WithValueArgs from the utilities entrypoint
(add WithValueArgs to the public type exports) so the type is visible to
consumers, or remove the external dependency by inlining the tuple/type directly
in the muteDeprecations signature; update the utilities index export list to
include WithValueArgs or modify the muteDeprecations declaration to use an
inline tuple type to resolve the ae-forgotten-export warning.

@apollo-librarian
Copy link
Copy Markdown

apollo-librarian bot commented Mar 10, 2026

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: 1a2e604ec1c7a835305f7982
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.

@@ -131,13 +131,3 @@ export function warnDeprecated(name: DeprecationName, cb: () => void) {
cb();
}
}
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.

Want to be extra safe and change the slot above to a global, too?

Something along the lines of

const muteAllDeprecations = Symbol.for("apollo.deprecations");
+const deprecationsSlot = Symbol.for("apollo.deprecations.slot");
-const global = untypedGlobal as { [muteAllDeprecations]?: boolean };
+const global = untypedGlobal as { [muteAllDeprecations]?: boolean, [deprecationsSlot]?: Slot<string[]> };

-const slot = new Slot<string[]>();
+const slot = (global[deprecationsSlot] ??= new Slot<string[]>());

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good call. Updated in 4143f5f

Copy link
Copy Markdown
Member

@phryneas phryneas left a comment

Choose a reason for hiding this comment

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

One suggestion, otherwise approved.

@github-actions github-actions bot added the auto-cleanup 🤖 label Mar 12, 2026
@jerelmiller jerelmiller merged commit 6b84ec0 into version-3.x Mar 12, 2026
32 checks passed
@jerelmiller jerelmiller deleted the jerel/fix-warnings branch March 12, 2026 17:44
@github-actions github-actions bot mentioned this pull request Mar 12, 2026
jerelmiller pushed a commit that referenced this pull request Mar 12, 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 version-3.x, this
PR will be updated.


# Releases
## @apollo/[email protected]

### Patch Changes

- [#13168](#13168)
[`6b84ec0`](6b84ec0)
Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix issue where
muting a deprecation from one entrypoint would not mute the warning when
checked in a different entrypoint. This caused some rogue deprecation
warnings to appear in the console even though the warnings should have
been muted.

- [#12970](#12970)
[`f91fab5`](f91fab5)
Thanks [@acemir](https://github.com/acemir)! - Add a deprecation message
for the `variableMatcher` option in `MockLink`.

- [#13168](#13168)
[`6b84ec0`](6b84ec0)
Thanks [@jerelmiller](https://github.com/jerelmiller)! - Ensure
deprecation warnings are properly silenced in React hooks when globally
disabled.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@jerelmiller jerelmiller mentioned this pull request Mar 12, 2026
jerelmiller added a commit that referenced this pull request Mar 12, 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 version-3.x, this
PR will be updated.


# Releases
## @apollo/[email protected]

### Patch Changes

- [#13168](#13168)
[`6b84ec0`](6b84ec0)
Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix issue where
muting a deprecation from one entrypoint would not mute the warning when
checked in a different entrypoint. This caused some rogue deprecation
warnings to appear in the console even though the warnings should have
been muted.

- [#12970](#12970)
[`f91fab5`](f91fab5)
Thanks [@acemir](https://github.com/acemir)! - Add a deprecation message
for the `variableMatcher` option in `MockLink`.

- [#13168](#13168)
[`6b84ec0`](6b84ec0)
Thanks [@jerelmiller](https://github.com/jerelmiller)! - Ensure
deprecation warnings are properly silenced in React hooks when globally
disabled.

---------

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

Labels

Projects

None yet

3 participants