Skip to content

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

@RinseV

Description

@RinseV

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    tanstack-queryTanStack Query related issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions