Skip to content

refactor(query): route axios isVue flag through the framework adapter#3631

Open
daugvinasr wants to merge 1 commit into
orval-labs:masterfrom
daugvinasr:refactor/route-isvue-through-framework-adapter
Open

refactor(query): route axios isVue flag through the framework adapter#3631
daugvinasr wants to merge 1 commit into
orval-labs:masterfrom
daugvinasr:refactor/route-isvue-through-framework-adapter

Conversation

@daugvinasr

@daugvinasr daugvinasr commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Please review using Hide Whitespace otherwise you will see many changed files.

This PR replaces the raw isVue in generateAxiosRequestFunction with the existing FrameworkAdapter. Vue's prop-transform, unref, and callback-wrapping behavior is now through adapter methods. This lets the four identical copies of generateRequestFunction collapse into a single shared default.

With next release where we want to do breaking changes we should discuss dropping unref from axios, as fetch and axios now behave differently and cause this code mess internally.

axios

export const showPetById = (
  petId: MaybeRef<string>,            // ← param typed MaybeRef
  options?: AxiosRequestConfig,
): Promise<AxiosResponse<Pet>> => {
  petId = unref(petId);               // ← unref INSIDE the body

  return axios.get(`/pets/${petId}`, options);
};

// caller passes the raw ref:
//   ({ signal }) => showPetById(petId, { signal, ...axiosOptions })

fetch

export const showPetById = async (
  petId: string,                      // ← plain value, no MaybeRef
  options?: RequestInit,
): Promise<showPetByIdResponse> => {
  const res = await fetch(getShowPetByIdUrl(petId), {   // ← no unref in body
    ...options,
    method: 'GET',
  });
  // ...
};

// caller unrefs at the call site:
//   ({ signal }) => showPetById(unref(petId), { signal, ...fetchOptions })

Summary by CodeRabbit

  • Refactor
    • Improved framework adapter abstraction to better separate concerns around reactive property unwrapping across different frameworks.
    • Consolidated request function generation logic into the default adapter implementation, reducing duplication across framework-specific configurations.
    • Enhanced consistency in how frameworks handle callback wrapping and property unwrapping for queries and mutations.

@coderabbitai

coderabbitai Bot commented Jun 20, 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3ca9ac3a-4c51-4882-9646-039cdc477110

📥 Commits

Reviewing files that changed from the base of the PR and between 101cade and 555960d.

📒 Files selected for processing (8)
  • packages/query/src/client.ts
  • packages/query/src/framework-adapter.ts
  • packages/query/src/frameworks/index.ts
  • packages/query/src/frameworks/react.ts
  • packages/query/src/frameworks/solid.ts
  • packages/query/src/frameworks/svelte.ts
  • packages/query/src/frameworks/vue.ts
  • packages/query/src/query-generator.ts

📝 Walkthrough

Walkthrough

The FrameworkAdapter interface splits getUnrefStatements into getRequestUnrefStatements and getQueryOptionsUnrefStatements, and adds wrapHookMutatorCallback. The withDefaults factory in frameworks/index.ts centralizes generateRequestFunction dispatch (Axios vs Fetch), using a composed adapter so defaults can reference the final merged object. React, Solid, Svelte, and Vue adapters remove their local generateRequestFunction overrides. generateAxiosRequestFunction gains an adapter parameter, and query-generator.ts switches to getQueryOptionsUnrefStatements.

Changes

FrameworkAdapter Interface Refactor and Centralization

Layer / File(s) Summary
FrameworkAdapter interface: new unref methods and wrapHookMutatorCallback
packages/query/src/framework-adapter.ts
Replaces getUnrefStatements with getRequestUnrefStatements and getQueryOptionsUnrefStatements, adds wrapHookMutatorCallback, and updates DefaultableFields to include these plus generateRequestFunction.
Vue adapter: new method implementations
packages/query/src/frameworks/vue.ts
Implements getRequestUnrefStatements, getQueryOptionsUnrefStatements (unrefs only named path params), and wrapHookMutatorCallback (identity); removes local generateRequestFunction and the @orval/fetch import.
withDefaults: composed adapter and centralized generateRequestFunction
packages/query/src/frameworks/index.ts
Refactors withDefaults to construct a composed adapter so defaults close over the final merged object. Adds default implementations for all new interface methods plus a generateRequestFunction that dispatches Axios vs Fetch. Updates generateQueryArguments and generateMutationOnSuccess to reference composed.
generateAxiosRequestFunction: adapter parameter and unref/callback delegation
packages/query/src/client.ts
Adds adapter: FrameworkAdapter parameter; uses adapter.transformProps, adapter.getRequestUnrefStatements, and adapter.wrapHookMutatorCallback in place of Vue-conditional logic across all template emission sites.
query-generator update; React/Solid/Svelte adapter cleanup
packages/query/src/query-generator.ts, packages/query/src/frameworks/react.ts, packages/query/src/frameworks/solid.ts, packages/query/src/frameworks/svelte.ts
query-generator switches to adapter.getQueryOptionsUnrefStatements. React, Solid, and Svelte adapters remove their local generateRequestFunction overrides and prune associated imports.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • orval-labs/orval#3379: Adds a regression test asserting that header unref is excluded from the Vue Query key getter while still applied to the HTTP call — directly validates the split unref behavior introduced in this PR.
  • orval-labs/orval#3630: Modifies Vue-specific generation in packages/query/src/client.ts by changing how isVue/unref logic is wired into hook mutator callbacks and request/options argument construction, overlapping with the same code paths changed here.

Suggested labels

tanstack-query

Suggested reviewers

  • melloware

Poem

🐇 Hop hop, the adapter grows!
One getUnrefStatements became two tidy rows,
wrapHookMutatorCallback joined the crew,
Vue, React, Solid, Svelte—now all pass through.
A composed adapter closes over the whole,
Clean code paths make this bunny feel whole! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main refactoring objective: routing the isVue flag through the framework adapter instead of handling it directly in generateAxiosRequestFunction.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ 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.

@daugvinasr daugvinasr force-pushed the refactor/route-isvue-through-framework-adapter branch 2 times, most recently from f9e2ec5 to b5b840e Compare June 20, 2026 13:02
@melloware melloware added the vue Vue related issue label Jun 20, 2026
@melloware melloware added this to the 8.19.0 milestone Jun 20, 2026
@daugvinasr daugvinasr force-pushed the refactor/route-isvue-through-framework-adapter branch from b5b840e to 5f39046 Compare June 20, 2026 13:16
@daugvinasr daugvinasr force-pushed the refactor/route-isvue-through-framework-adapter branch from 5f39046 to 555960d Compare June 20, 2026 13:30
@daugvinasr daugvinasr changed the title Refactor/route isvue through framework adapter refactor(query): route axios isVue flag through the framework adapter Jun 20, 2026
@daugvinasr daugvinasr marked this pull request as ready for review June 20, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vue Vue related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants