Ensure that compact and mergeOptions preserve symbol keys.#13094
Ensure that compact and mergeOptions preserve symbol keys.#13094
compact and mergeOptions preserve symbol keys.#13094Conversation
🦋 Changeset detectedLatest 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 |
commit: |
✅ Docs preview has no changesThe preview was not built because there were no changes. Build ID: 13f1bd80c193e6cd2334425c |
There was a problem hiding this comment.
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
compactfunction to preserve symbol keys by usingReflect.ownKeys()instead ofObject.keys() - Added comprehensive test coverage for symbol key preservation in the
compactutility - Added integration test to verify symbol keys are forwarded correctly through
client.watchQuerywithdefaultOptions
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.
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>
Fixes #13093