Silence warnings that should be muted#13168
Conversation
🦋 Changeset detectedLatest commit: 0a12305 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis 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
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment Tip CodeRabbit can generate a title for your PR based on the changes.Add |
commit: |
147d9bc to
c17d88b
Compare
| muteDeprecations, | ||
| warnRemovedOption, | ||
| } from "../../utilities/deprecation/index.js"; | ||
| import { muteDeprecations, warnRemovedOption } from "../../utilities/index.js"; |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
Major facepalm moment discovering this 🤦♂️
There was a problem hiding this comment.
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) fromsrc/utilities/index.tsand 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. |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
src/core/__tests__/ObservableQuery.ts (1)
34-34: ImportmuteDeprecationsfrom 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../../utilitieskeeps 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/internaldirectly. The repo guideline asks internal APIs to be consumed through the@apollo/client/*/internalentrypoints instead of relative source paths.As per coding guidelines, "Use
@apollo/client/*/internalpaths 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
⛔ Files ignored due to path filters (1)
src/__tests__/__snapshots__/exports.ts.snapis 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.mdsrc/cache/core/cache.tssrc/cache/inmemory/inMemoryCache.tssrc/core/ApolloClient.tssrc/core/ObservableQuery.tssrc/core/QueryInfo.tssrc/core/QueryManager.tssrc/core/__tests__/ObservableQuery.tssrc/link/core/ApolloLink.tssrc/react/hoc/graphql.tsxsrc/react/hoc/mutation-hoc.tsxsrc/react/hoc/query-hoc.tsxsrc/react/hoc/subscription-hoc.tsxsrc/react/hooks/__tests__/useQuery.test.tsxsrc/react/hooks/internal/useWarnRemoved.tssrc/react/hooks/internal/useWarnRemovedOption.tssrc/react/hooks/useBackgroundQuery.tssrc/react/hooks/useFragment.tssrc/react/hooks/useLazyQuery.tssrc/react/hooks/useLoadableQuery.tssrc/react/hooks/useQuery.tssrc/react/hooks/useSuspenseQuery.tssrc/react/internal/cache/QueryReference.tssrc/react/parser/index.tssrc/react/query-preloader/createQueryPreloader.tssrc/testing/internal/disposables/index.tssrc/testing/internal/disposables/withMutedDeprecations.tssrc/testing/react/MockedProvider.tsxsrc/testing/react/__tests__/MockedProvider.test.tsxsrc/utilities/deprecation/index.tssrc/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/*/internalpaths 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.tssrc/react/hooks/useSuspenseQuery.tssrc/testing/react/MockedProvider.tsxsrc/react/internal/cache/QueryReference.tssrc/react/hooks/useLoadableQuery.tssrc/link/core/ApolloLink.tssrc/utilities/index.tssrc/react/hoc/query-hoc.tsxsrc/testing/internal/disposables/index.tssrc/core/__tests__/ObservableQuery.tssrc/core/ApolloClient.tssrc/react/hooks/__tests__/useQuery.test.tsxsrc/react/hooks/useFragment.tssrc/react/hoc/graphql.tsxsrc/react/hooks/useLazyQuery.tssrc/react/hooks/useQuery.tssrc/react/hoc/subscription-hoc.tsxsrc/core/QueryInfo.tssrc/react/hoc/mutation-hoc.tsxsrc/core/ObservableQuery.tssrc/react/hooks/internal/useWarnRemovedOption.tssrc/core/QueryManager.tssrc/react/query-preloader/createQueryPreloader.tssrc/cache/core/cache.tssrc/react/parser/index.tssrc/react/hooks/useBackgroundQuery.tssrc/testing/internal/disposables/withMutedDeprecations.tssrc/react/hooks/internal/useWarnRemoved.tssrc/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.tssrc/testing/internal/disposables/index.tssrc/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.mdsrc/react/hooks/useSuspenseQuery.tssrc/testing/react/MockedProvider.tsxsrc/react/internal/cache/QueryReference.tssrc/link/core/ApolloLink.tssrc/react/hoc/query-hoc.tsxsrc/core/ApolloClient.tssrc/react/hooks/__tests__/useQuery.test.tsxsrc/react/hoc/graphql.tsxsrc/react/hooks/useLazyQuery.tssrc/react/hooks/useQuery.ts.api-reports/api-report-react_internal.api.mdsrc/core/QueryInfo.tssrc/react/hoc/mutation-hoc.tsxsrc/react/parser/index.ts.changeset/two-rings-work.mdsrc/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.mdsrc/core/ApolloClient.tssrc/react/hooks/__tests__/useQuery.test.tsxsrc/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.tsxsrc/react/hooks/__tests__/useQuery.test.tsxsrc/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.tssrc/react/hoc/subscription-hoc.tsxsrc/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.tssrc/react/hooks/__tests__/useQuery.test.tsx.api-reports/api-report-react_internal.api.mdsrc/core/QueryInfo.tssrc/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
muteDeprecationsandwarnRemovedOption. 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
canonizeResultsdeprecation 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
graphqlHOC 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
warnRemovedOptionthrough 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
muteDeprecationsthrough the main utilities barrel. This fix directly addresses issue#13057, ensuring that internal calls tocache.diffwithcanonizeResultsandobservableQuery.getLastError()properly suppress deprecation warnings when muting is enabled.src/testing/internal/disposables/index.ts (1)
5-5: Good barrel export.Re-exporting
withMutedDeprecationshere 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 onMockLinkwarnings 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
withCleanupmakes 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.watchQuerywith both deprecation names fixes the internal warning path without masking the hook-level warnings emitted earlier inuseQuery_.src/core/__tests__/ObservableQuery.ts (1)
1834-1834: Good test hardening.Using
withMutedDeprecations()here keeps the warning assertion targeted at therefetch({ 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. BothwithMutedDeprecations()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.
| // 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; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# First, let's understand the repository structure
git ls-files | grep -E '\.(api\.md|d\.ts|ts)$' | head -20Repository: apollographql/apollo-client
Length of output: 919
🏁 Script executed:
# Search for WithValueArgs definition
rg 'WithValueArgs' --type ts --type tsx -A 2 -B 2Repository: apollographql/apollo-client
Length of output: 98
🏁 Script executed:
# Find the entrypoint (index.d.ts)
fd 'index\.d\.ts' --type fRepository: apollographql/apollo-client
Length of output: 102
🏁 Script executed:
# Search for WithValueArgs with correct type
rg 'WithValueArgs' --type ts -A 2 -B 2Repository: apollographql/apollo-client
Length of output: 846
🏁 Script executed:
# Find the utilities entry point
fd 'index' src/utilities --type fRepository: 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 -100Repository: apollographql/apollo-client
Length of output: 4432
🏁 Script executed:
# Check what's exported from utilities index
cat src/utilities/index.tsRepository: apollographql/apollo-client
Length of output: 4517
🏁 Script executed:
# Check if muteDeprecations is exported from the utilities entrypoint
rg 'muteDeprecations' src/utilities/index.tsRepository: apollographql/apollo-client
Length of output: 90
🏁 Script executed:
# Check the deprecation module for all exports
cat src/utilities/deprecation/index.tsRepository: 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.
✅ Docs preview has no changesThe preview was not built because there were no changes. Build ID: 1a2e604ec1c7a835305f7982 ✅ AI Style Review — No Changes DetectedNo MDX files were changed in this pull request. Review Log: View detailed log
|
| @@ -131,13 +131,3 @@ export function warnDeprecated(name: DeprecationName, cb: () => void) { | |||
| cb(); | |||
| } | |||
| } | |||
There was a problem hiding this comment.
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[]>());
phryneas
left a comment
There was a problem hiding this comment.
One suggestion, otherwise approved.
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>
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]>
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
New Features