Skip to content

feat(vue-query): support mutationInvalidates #3403

@strebl

Description

@strebl

Description

mutationInvalidates works on react-query, svelte-query, and angular-query but is a no-op on vue-query. Same config, no codegen difference, no warning. Asking for vue-query parity.

Current behavior

With client: 'vue-query' and a query.mutationInvalidates rule, the generated mutation hook does not get the queryClient parameter, the skipInvalidation option, or the onSuccess invalidation block. The rule is silently ignored.

The Vue adapter explicitly opts out in packages/query/src/frameworks/vue.ts:

supportsMutationInvalidation() { return false },
generateMutationOnSuccess() { return '' },

…which the shared generator gates on:

const hasInvalidation =
  uniqueInvalidates.length > 0 && adapter.supportsMutationInvalidation()

Versions: orval@8.11.0, @tanstack/vue-query@5.x.

Proposed behavior

When client: 'vue-query' matches a mutationInvalidates rule, emit the same queryClient / skipInvalidation / onSuccess-invalidation surface as the React Query output (adjusted for Vue's TanStack v5 onSuccess signature, which the adapter already tracks via hasQueryV5WithMutationContextOnSuccess / hasQueryV5WithRequiredContextOnSuccess).

Proposed solution

Port the React adapter's mutation-invalidation methods into packages/query/src/frameworks/vue.ts: flip supportsMutationInvalidation() to true, implement generateMutationOnSuccess, and update generateMutationImplementation / generateMutationHookBody to thread queryClient and a useQueryClient() fallback. The shared mutation-generator.ts already handles cross-file getYyyQueryKey imports once the adapter opts in.

solid-query is in the same state and is a candidate for the same change.

Happy to PR if someone can confirm the approach.

Metadata

Metadata

Assignees

Labels

vueVue related issue
No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions