Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to use path parameters onuseMutation?#2009

Unanswered
bangonkali asked this question inQ&A
Discussion options

I am able to query using path params but I am not able to do so using useMutations? Is this a limitation? Or am I doing it wrong?

image

* Notice the red squiggly at the end of the last example on parametera.

I have added the following totsconfig:

"noUncheckedIndexedAccess": true,

I get the following error when forcing a build:

$ tsc -b && vite buildsrc/routes/_private/dashboard/_layout.index.lazy.tsx:37:70 - error TS2559: Type '{ params: { path: { tenantId: string; }; }; }' has no properties in common with type 'Omit<UseMutationOptions<undefined, never, FetchOptions<{ parameters: { query?: undefined; header?: undefined; path: { tenantId: string; }; cookie?: undefined; }; requestBody?: undefined; responses: { 200: { headers: { [name: string]: unknown; }; content?: undefined; }; }; }>, unknown>, "mutationKey" | "mutationFn">'.37               client.useMutation("delete", "/api/Tenant/{tenantId}", a);                                                                        ~Found 1 error.

However, if I just mouse hover, I get some sort of indication that tenantId is part of the parameter based on the following tip:
image

If I type something I get the following error:
image

Then I tried a couple of variations and none worked :(
image

I am not seeing anything different from myget vsdelete json openapi schema.

"/api/Tenant/{tenantId}": {"delete": {"tags": ["Tenant"        ],"parameters": [          {"name":"tenantId","in":"path","required":true,"schema": {"type":"string","format":"uuid"            }          }        ],"responses": {"200": {"description":"OK"          }        },"security": [          {"Bearer": [ ]          }        ]      },"get": {"tags": ["Tenant"        ],"parameters": [          {"name":"tenantId","in":"path","required":true,"schema": {"type":"string","format":"uuid"            }          }        ],"responses": {"200": {"description":"OK","content": {"text/plain": {"schema": {"$ref":"#/components/schemas/TenantInfo"                }              },"application/json": {"schema": {"$ref":"#/components/schemas/TenantInfo"                }              },"text/json": {"schema": {"$ref":"#/components/schemas/TenantInfo"                }              }            }          }        },"security": [          {"Bearer": [ ]          }        ]      }    },

There also seems nothing suspicious in the generatedd.ts file.

    "/api/Tenant/{tenantId}": {        parameters: {            query?: never;            header?: never;            path?: never;            cookie?: never;        };        get: {            parameters: {                query?: never;                header?: never;                path: {                    tenantId: string;                };                cookie?: never;            };            requestBody?: never;            responses: {                /** @description OK */                200: {                    headers: {                        [name: string]: unknown;                    };                    content: {                        "text/plain": components["schemas"]["TenantInfo"];                        "application/json": components["schemas"]["TenantInfo"];                        "text/json": components["schemas"]["TenantInfo"];                    };                };            };        };        put?: never;        post?: never;        delete: {            parameters: {                query?: never;                header?: never;                path: {                    tenantId: string;                };                cookie?: never;            };            requestBody?: never;            responses: {                /** @description OK */                200: {                    headers: {                        [name: string]: unknown;                    };                    content?: never;                };            };        };        options?: never;        head?: never;        patch?: never;        trace?: never;    };    ```
You must be logged in to vote

Replies: 3 comments

Comment options

I think this may be an issue with the library in general—we have some type issues with the library currently that we’re working through. Will investigate fixing this.

You must be logged in to vote
0 replies
Comment options

Seems like the params need to be included in the mutate payload next to the body;

{  params: { path: { id: tenantId } },  body: formData,}

Would be nice if it was included in theuseMutiation hook as a default instead.

You must be logged in to vote
0 replies
Comment options

There is no option object you can pass like in useQuery. So there is currently no option to pass path parameters when using useMutation.

You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
openapi-react-queryRelevant to openapi-react-query
4 participants
@bangonkali@drwpow@mnlfischer@jensjakob

[8]ページ先頭

©2009-2025 Movatter.jp