Skip to content

feat(vue-query): add usePrefetchQuery and usePrefetchInfiniteQuery#10371

Closed
thalassophilia wants to merge 1 commit intoTanStack:mainfrom
thalassophilia:feat/vue-prefetch-composables
Closed

feat(vue-query): add usePrefetchQuery and usePrefetchInfiniteQuery#10371
thalassophilia wants to merge 1 commit intoTanStack:mainfrom
thalassophilia:feat/vue-prefetch-composables

Conversation

@thalassophilia
Copy link
Copy Markdown

@thalassophilia thalassophilia commented Apr 1, 2026

🎯 Changes

Add usePrefetchQuery and usePrefetchInfiniteQuery to @tanstack/vue-query.

This PR:

  • adds usePrefetchQuery and usePrefetchInfiniteQuery to the Vue adapter
  • supports reactive options via refs and getters
  • only prefetches when the query state does not already exist in the cache
  • adds runtime and type tests for both composables
  • adds Vue reference docs for both APIs

✅ 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).

Validated with:

  • npx nx run @tanstack/vue-query:test:lib
  • npx nx run @tanstack/vue-query:test:eslint

Summary by CodeRabbit

  • Documentation
    • Added API reference documentation for usePrefetchQuery
    • Added API reference documentation for usePrefetchInfiniteQuery

@github-actions github-actions bot added documentation Improvements or additions to documentation package: vue-query labels Apr 1, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 1, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f9e50b51-4eb3-49d4-aaa5-248c29906c13

📥 Commits

Reviewing files that changed from the base of the PR and between 037ee8e and a158029.

📒 Files selected for processing (3)
  • docs/config.json
  • docs/framework/vue/reference/usePrefetchInfiniteQuery.md
  • docs/framework/vue/reference/usePrefetchQuery.md

📝 Walkthrough

Walkthrough

Two new Vue framework documentation reference files are introduced for usePrefetchQuery and usePrefetchInfiniteQuery hooks, with corresponding navigation entries added to the configuration. Both files use template-based documentation generation with React reference sources and Vue-specific package/function name replacements.

Changes

Cohort / File(s) Summary
Navigation Configuration
docs/config.json
Added two new Vue API reference entries pointing to usePrefetchQuery and usePrefetchInfiniteQuery documentation pages.
Vue Reference Documentation
docs/framework/vue/reference/usePrefetchQuery.md, docs/framework/vue/reference/usePrefetchInfiniteQuery.md
New documentation files with frontmatter metadata and replace mappings to adapt React query documentation to Vue query equivalents (package name and hook references).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Poem

🐰 Two prefetch hooks hop into the garden,
Vue docs now bloom in verdant fashion,
From React's path they gently transform,
Navigation guides the curious warren,
Query hopping, faster than the norm! 🌱

🚥 Pre-merge checks | ✅ 2 | ❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding two new composables (usePrefetchQuery and usePrefetchInfiniteQuery) to vue-query.
Description check ✅ Passed Pull request description comprehensively covers all required template sections with complete information about changes, testing, and release impact.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/vue-query/src/usePrefetchInfiniteQuery.ts (1)

57-113: Consider extracting shared prefetch internals to avoid drift

isGetter, dev-scope warning, option resolution, deep unref clone, and state-guard logic are duplicated with packages/vue-query/src/usePrefetchQuery.ts. A small internal helper would reduce long-term divergence risk.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/vue-query/src/usePrefetchInfiniteQuery.ts` around lines 57 - 113,
The prefetch logic in usePrefetchInfiniteQuery (isGetter, dev-scope warning,
option resolution, cloneDeepUnref, state-guard and prefetch call using
client.getQueryState + prefetchInfiniteQuery inside watchEffect) is duplicated
with usePrefetchQuery; extract a small internal helper (e.g., prefetchHelper or
resolveAndPrefetch) that accepts the options ref/getter, the client, and a
prefetch function (prefetchQuery vs prefetchInfiniteQuery) to centralize: move
the dev-scope warning, isGetter check, resolution/unref+cloneDeepUnref, and
guarded getQueryState check into that helper, then call it from both
usePrefetchQuery and usePrefetchInfiniteQuery passing the appropriate prefetch
function to avoid future drift.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/vue-query/src/usePrefetchInfiniteQuery.ts`:
- Around line 57-113: The prefetch logic in usePrefetchInfiniteQuery (isGetter,
dev-scope warning, option resolution, cloneDeepUnref, state-guard and prefetch
call using client.getQueryState + prefetchInfiniteQuery inside watchEffect) is
duplicated with usePrefetchQuery; extract a small internal helper (e.g.,
prefetchHelper or resolveAndPrefetch) that accepts the options ref/getter, the
client, and a prefetch function (prefetchQuery vs prefetchInfiniteQuery) to
centralize: move the dev-scope warning, isGetter check,
resolution/unref+cloneDeepUnref, and guarded getQueryState check into that
helper, then call it from both usePrefetchQuery and usePrefetchInfiniteQuery
passing the appropriate prefetch function to avoid future drift.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b0c099a0-e4b8-4a90-a62c-afacf87ccf19

📥 Commits

Reviewing files that changed from the base of the PR and between 75052a7 and 037ee8e.

📒 Files selected for processing (11)
  • .changeset/wild-planes-report.md
  • docs/config.json
  • docs/framework/vue/reference/usePrefetchInfiniteQuery.md
  • docs/framework/vue/reference/usePrefetchQuery.md
  • packages/vue-query/src/__tests__/usePrefetchInfiniteQuery.test-d.ts
  • packages/vue-query/src/__tests__/usePrefetchInfiniteQuery.test.ts
  • packages/vue-query/src/__tests__/usePrefetchQuery.test-d.ts
  • packages/vue-query/src/__tests__/usePrefetchQuery.test.ts
  • packages/vue-query/src/index.ts
  • packages/vue-query/src/usePrefetchInfiniteQuery.ts
  • packages/vue-query/src/usePrefetchQuery.ts

@thalassophilia thalassophilia force-pushed the feat/vue-prefetch-composables branch from 037ee8e to a158029 Compare April 1, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation package: vue-query

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants