Skip to content

fix(preact-query/usePrefetchQuery): replace deprecated 'queryClient.fetchQuery' with 'queryClient.query' - #11274

Merged
sukvvon merged 2 commits into
mainfrom
fix/preact-use-prefetch-query-deprecated-fetch-query
Aug 24, 2026
Merged

fix(preact-query/usePrefetchQuery): replace deprecated 'queryClient.fetchQuery' with 'queryClient.query'#11274
sukvvon merged 2 commits into
mainfrom
fix/preact-use-prefetch-query-deprecated-fetch-query

Conversation

@sukvvon

@sukvvon sukvvon commented Aug 24, 2026

Copy link
Copy Markdown
Member

🎯 Changes

usePrefetchQuery in @tanstack/preact-query still called queryClient.fetchQuery, which is @deprecated in favor of queryClient.query. react-query's usePrefetchQuery already uses client.query, and preact-query's own usePrefetchInfiniteQuery already uses client.infiniteQuery — this closes the last remaining spot using the deprecated method.

Swaps the call from client.fetchQuery(options) to client.query(options). No behavior change: query() performs the same staleness check, retry default, and cache build as fetchQuery(); its only addition is running select on the returned promise, which prefetch discards.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Bug Fixes

    • Improved query prefetching so missing data is loaded using the supported query approach.
    • Preserved handling for intentionally ignored promise rejections, helping prevent unnecessary errors during prefetching.
    • Updated prefetch behavior for greater compatibility with current query management practices.
  • Documentation

    • Added release notes describing the query prefetching improvements.

@sukvvon sukvvon self-assigned this Aug 24, 2026
@nx-cloud

nx-cloud Bot commented Aug 24, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit ab98b72

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 1m 2s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 8s View ↗

☁️ Nx Cloud last updated this comment at 2026-08-24 18:45:33 UTC

@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b4186913-a7eb-41c5-8136-7650c0957a88

📥 Commits

Reviewing files that changed from the base of the PR and between ab98b72 and 0e0b2f4.

📒 Files selected for processing (1)
  • .changeset/khaki-donkeys-clap.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/khaki-donkeys-clap.md

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

usePrefetchQuery now uses QueryClient.query instead of deprecated fetchQuery. Rejected promises still pass to noop. A patch changeset documents the update.

Changes

Preact query prefetch migration

Layer / File(s) Summary
Update the prefetch call
packages/preact-query/src/usePrefetchQuery.tsx, .changeset/khaki-donkeys-clap.md
The missing-query path calls client.query(options) and preserves rejected-promise handling. The changeset documents a patch release.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 0e0b2

This is a localized replacement of a deprecated prefetch API with its intended successor, plus release metadata; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. (1 skipped: 1 unsupported.) Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the replacement of the deprecated API in usePrefetchQuery.
Description check ✅ Passed The description explains the change and motivation, completes the required checklist, and documents the release impact and changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/preact-use-prefetch-query-deprecated-fetch-query

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

1 package(s) bumped directly, 24 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/preact-query 5.102.2 → 5.102.3 Changeset
@tanstack/angular-query-experimental 5.102.2 → 5.102.3 Dependent
@tanstack/angular-query-persist-client 5.102.2 → 5.102.3 Dependent
@tanstack/eslint-plugin-query 5.102.2 → 5.102.3 Dependent
@tanstack/lit-query 0.2.14 → 0.2.15 Dependent
@tanstack/preact-query-devtools 5.102.2 → 5.102.3 Dependent
@tanstack/preact-query-persist-client 5.102.2 → 5.102.3 Dependent
@tanstack/query-async-storage-persister 5.102.2 → 5.102.3 Dependent
@tanstack/query-broadcast-client-experimental 5.102.2 → 5.102.3 Dependent
@tanstack/query-core 5.102.2 → 5.102.3 Dependent
@tanstack/query-devtools 5.102.2 → 5.102.3 Dependent
@tanstack/query-persist-client-core 5.102.2 → 5.102.3 Dependent
@tanstack/query-sync-storage-persister 5.102.2 → 5.102.3 Dependent
@tanstack/react-query 5.102.2 → 5.102.3 Dependent
@tanstack/react-query-devtools 5.102.2 → 5.102.3 Dependent
@tanstack/react-query-next-experimental 5.102.2 → 5.102.3 Dependent
@tanstack/react-query-persist-client 5.102.2 → 5.102.3 Dependent
@tanstack/solid-query 5.102.2 → 5.102.3 Dependent
@tanstack/solid-query-devtools 5.102.2 → 5.102.3 Dependent
@tanstack/solid-query-persist-client 5.102.2 → 5.102.3 Dependent
@tanstack/svelte-query 6.1.42 → 6.1.43 Dependent
@tanstack/svelte-query-devtools 6.1.42 → 6.1.43 Dependent
@tanstack/svelte-query-persist-client 6.1.42 → 6.1.43 Dependent
@tanstack/vue-query 5.102.2 → 5.102.3 Dependent
@tanstack/vue-query-devtools 6.1.42 → 6.1.43 Dependent

@pkg-pr-new

pkg-pr-new Bot commented Aug 24, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-experimental@11274

@tanstack/eslint-plugin-query

npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@11274

@tanstack/lit-query

npm i https://pkg.pr.new/@tanstack/lit-query@11274

@tanstack/preact-query

npm i https://pkg.pr.new/@tanstack/preact-query@11274

@tanstack/preact-query-devtools

npm i https://pkg.pr.new/@tanstack/preact-query-devtools@11274

@tanstack/preact-query-persist-client

npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@11274

@tanstack/query-async-storage-persister

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@11274

@tanstack/query-broadcast-client-experimental

npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@11274

@tanstack/query-core

npm i https://pkg.pr.new/@tanstack/query-core@11274

@tanstack/query-devtools

npm i https://pkg.pr.new/@tanstack/query-devtools@11274

@tanstack/query-persist-client-core

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@11274

@tanstack/query-sync-storage-persister

npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@11274

@tanstack/react-query

npm i https://pkg.pr.new/@tanstack/react-query@11274

@tanstack/react-query-devtools

npm i https://pkg.pr.new/@tanstack/react-query-devtools@11274

@tanstack/react-query-next-experimental

npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@11274

@tanstack/react-query-persist-client

npm i https://pkg.pr.new/@tanstack/react-query-persist-client@11274

@tanstack/solid-query

npm i https://pkg.pr.new/@tanstack/solid-query@11274

@tanstack/solid-query-devtools

npm i https://pkg.pr.new/@tanstack/solid-query-devtools@11274

@tanstack/solid-query-persist-client

npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@11274

@tanstack/svelte-query

npm i https://pkg.pr.new/@tanstack/svelte-query@11274

@tanstack/svelte-query-devtools

npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@11274

@tanstack/svelte-query-persist-client

npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@11274

@tanstack/vue-query

npm i https://pkg.pr.new/@tanstack/vue-query@11274

@tanstack/vue-query-devtools

npm i https://pkg.pr.new/@tanstack/vue-query-devtools@11274

commit: 0e0b2f4

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 11.97 KB (0%)
react minimal 8.92 KB (0%)

@sukvvon
sukvvon merged commit 714c285 into main Aug 24, 2026
9 checks passed
@sukvvon
sukvvon deleted the fix/preact-use-prefetch-query-deprecated-fetch-query branch August 24, 2026 19:06
@github-actions github-actions Bot mentioned this pull request Aug 24, 2026
const client = useQueryClient(queryClient)

if (!client.getQueryState(options.queryKey)) {
void client.fetchQuery(options).catch(noop)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Whoops. That should have been query when I filed #10669

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants