Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a react-query default mutation key without having to enable the requestOptions setting #1947

Open
RinseV opened this issue Feb 27, 2025 · 0 comments
Labels
tanstack-query TanStack Query related issue

Comments

@RinseV
Copy link
Contributor

RinseV commented Feb 27, 2025

This PR introduced default mutation keys for mutations based on the operation ID. This is a nice addition, but currently not usable in combination with the requestOptions configuration option. When setting requestOptions to false in the config:

output: {
  mode: "single",
  target: "src/generated/api/index.ts",
  schemas: "src/generated/models",
  client: "react-query",
  override: {
    requestOptions: false,
  },
},

No default mutation keys are generated. This is because the aforementioned PR only generates the mutation keys if this option is set to true (or left out entirely).

I personally prefer to keep this option set to false because I don't need to override any options for the request itself and would rather stick close to to the react-query API for the hook options (i.e. being able to update the query options via useQuery({ retry: false }) instead of useQuery({ query: { retry: false } })), but I'd still like to get default mutation keys.

I'm not sure if this is technically feasible since I'm sure there's a reason the keys are only generated if the requestOptions config isn't true (default).

@melloware melloware added the tanstack-query TanStack Query related issue label Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tanstack-query TanStack Query related issue
Projects
None yet
Development

No branches or pull requests

2 participants