Skip to content

Ensure that compact and mergeOptions preserve symbol keys.#13094

Merged
phryneas merged 1 commit intomainfrom
pr/fix-13093
Jan 13, 2026
Merged

Ensure that compact and mergeOptions preserve symbol keys.#13094
phryneas merged 1 commit intomainfrom
pr/fix-13093

Conversation

@phryneas
Copy link
Member

@phryneas phryneas commented Jan 13, 2026

Fixes #13093

@changeset-bot
Copy link

changeset-bot bot commented Jan 13, 2026

🦋 Changeset detected

Latest commit: 9533af4

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

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 13, 2026

npm i https://pkg.pr.new/apollographql/apollo-client/@apollo/client@13094

commit: 9533af4

@phryneas phryneas marked this pull request as ready for review January 13, 2026 10:35
@apollo-librarian
Copy link

apollo-librarian bot commented Jan 13, 2026

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: 13f1bd80c193e6cd2334425c
Build Logs: View logs

Copy link
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 fixes a bug where symbol keys (specifically variablesUnknownSymbol) were lost when merging options with defaultOptions in Apollo Client. The fix updates the internal compact utility function to use Reflect.ownKeys() instead of Object.keys(), which ensures both string and symbol property keys are preserved during the merge operation.

Changes:

  • Updated compact function to preserve symbol keys by using Reflect.ownKeys() instead of Object.keys()
  • Added comprehensive test coverage for symbol key preservation in the compact utility
  • Added integration test to verify symbol keys are forwarded correctly through client.watchQuery with defaultOptions

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/utilities/internal/compact.ts Changed from Object.keys() to Reflect.ownKeys() to iterate over all property keys including symbols
src/utilities/internal/tests/compact.test.ts Added test case verifying symbol keys are preserved, merged, and filtered correctly
src/core/tests/ApolloClient/general.test.ts Added integration test confirming variablesUnknownSymbol is preserved when defaultOptions are present
.changeset/sweet-hairs-impress.md Added changeset documenting the fix as a patch with appropriate warnings about internal utilities

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@jerelmiller jerelmiller left a comment

Choose a reason for hiding this comment

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

Good catch!

@github-actions github-actions bot added the auto-cleanup 🤖 label Jan 13, 2026
@phryneas phryneas merged commit 9cbe2c2 into main Jan 13, 2026
51 checks passed
@github-actions github-actions bot mentioned this pull request Jan 13, 2026
jerelmiller pushed a commit that referenced this pull request Jan 13, 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 main, this PR will
be updated.


# Releases
## @apollo/[email protected]

### Patch Changes

- [#13094](#13094)
[`9cbe2c2`](9cbe2c2)
Thanks [@phryneas](https://github.com/phryneas)! - Ensure that `compact`
and `mergeOptions` preserve symbol keys.

This fixes an issue where the change introduced in 4.0.11 via #13049
would not
    be applied if `defaultOptions` for `watchQuery` were declared.

Please note that `compact` and `mergeOptions` are considered internal
utilities
    and they might have similar behavior changes in future releases.
Do not use them in your application code - a change like this is not
considered
    breaking and will not be announced as such.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refetchQueries ignores skipToken when global defaultOptions.watchQuery.fetchPolicy is set

3 participants