Skip to content

Fix client.query using defaultOptions.watchQuery#13135

Merged
jerelmiller merged 7 commits intomainfrom
jerel/query-default-opts
Feb 18, 2026
Merged

Fix client.query using defaultOptions.watchQuery#13135
jerelmiller merged 7 commits intomainfrom
jerel/query-default-opts

Conversation

@jerelmiller
Copy link
Member

@jerelmiller jerelmiller commented Feb 5, 2026

Fixes #13136

@changeset-bot
Copy link

changeset-bot bot commented Feb 5, 2026

🦋 Changeset detected

Latest 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

@jerelmiller jerelmiller force-pushed the jerel/query-default-opts branch from aec4f9f to 3472508 Compare February 5, 2026 19:05
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 5, 2026

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

commit: f7881f7

@apollo-librarian
Copy link

apollo-librarian bot commented Feb 5, 2026

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: 261ae2b517301bef5ef73f11
Build Logs: View logs

@jerelmiller jerelmiller changed the title Test reproduction for client.query defaultOptions using watchQuery Fix client.query using defaultOptions.watchQuery Feb 5, 2026
@jerelmiller jerelmiller marked this pull request as ready for review February 5, 2026 19:41
@jerelmiller jerelmiller requested review from Copilot and phryneas and removed request for phryneas February 5, 2026 19:41
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 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.watchQuery in fetchObservableWithInfo method
  • Added proper merging of defaultOptions.watchQuery for refetchQueries operations (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

@jerelmiller jerelmiller force-pushed the jerel/query-default-opts branch from 3866e61 to b86dd97 Compare February 5, 2026 19:44
@github-actions github-actions bot added the auto-cleanup 🤖 label Feb 18, 2026
@jerelmiller jerelmiller merged commit fd42142 into main Feb 18, 2026
32 of 33 checks passed
@jerelmiller jerelmiller deleted the jerel/query-default-opts branch February 18, 2026 19:08
@github-actions github-actions bot mentioned this pull request Feb 18, 2026
jerelmiller pushed a commit that referenced this pull request Feb 19, 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/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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

client.query uses defaultOptions.watchQuery

2 participants

Comments