Skip to content

Options parameter is missing in useMutation #2354

Open
@mnlfischer

Description

@mnlfischer

openapi-react-query version

0.5.0

Description

The useMutation function is missing the Options parameter like in useQuery.

useQuery Docs:

  • options

    • The fetch options to use for the request.
    • Only required if the OpenApi schema requires parameters.
    • The options params are used as key. See Query Keys for more information.

This option parameter missing in useMutation and makes it impossible to pass path parameters to the types path.
Example:

api.useMutation("post", "/todos/{todo_id}/actions/delete");

Using template literal will throw an error because the path is typed.

Reproduction

Create a useMutation with path parameter and try to pass options. It is also missing in the docs so I guess this is not complicated to reproduce due to a completely missing feature. I would declare it as a bug because the function is currently not usable for urls with path parameters

Expected result

Add options with path parameters to useMutation as an argument.

api.useMutation("post", "/todos/{todo_id}/actions/delete", {
    params: {
      path: {
        todo_id,
      },
    },
  });

Extra

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingopenapi-react-queryRelevant to openapi-react-query

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions