Fix client.query using defaultOptions.watchQuery#13135
Conversation
🦋 Changeset detectedLatest commit: 0408def 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 |
aec4f9f to
3472508
Compare
commit: |
✅ Docs preview has no changesThe preview was not built because there were no changes. Build ID: 261ae2b517301bef5ef73f11 |
client.query defaultOptions using watchQueryclient.query using defaultOptions.watchQuery
There was a problem hiding this comment.
Pull request overview
This PR fixes an issue where client.query was incorrectly applying options from defaultOptions.watchQuery instead of defaultOptions.query. The issue occurred because the fetchObservableWithInfo method in QueryManager.ts was reading defaults from watchQuery for all query operations, even those initiated by client.query.
Changes:
- Removed the inappropriate reading of
defaultOptions.watchQueryinfetchObservableWithInfomethod - Added proper merging of
defaultOptions.watchQueryforrefetchQueriesoperations (which should use watchQuery defaults) - Added comprehensive tests to verify the fix
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/core/__tests__/client.query/defaultOptions.test.ts |
New test file verifying that client.query uses defaultOptions.query and not defaultOptions.watchQuery |
src/core/__tests__/client.mutate/refetchQueries.test.ts |
New test file verifying that refetchQueries correctly applies defaultOptions.watchQuery |
src/core/QueryManager.ts |
Removes incorrect reading of defaultOptions.watchQuery in fetchObservableWithInfo and adds proper merging for refetchQueries |
.changeset/fair-hairs-move.md |
Documents the bug fix in the changeset |
.api-reports/api-report.api.md |
API report line number update due to code changes |
.api-reports/api-report-core.api.md |
API report line number update due to code changes |
3866e61 to
b86dd97
Compare
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/client@4.1.5 ### Patch Changes - [#13155](#13155) [`3ba1583`](3ba1583) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix an issue where `useQuery` would poll with `pollInterval` when `skip` was initialized to `true`. - [#13135](#13135) [`fd42142`](fd42142) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix issue where `client.query` would apply options from `defaultOptions.watchQuery`. Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Fixes #13136