Shaddix / react-query-swagger

Generates react-query hooks based on Swagger API definitions
MIT License
119 stars 4 forks source link

TypeError: this[#client].defaultMutationOptions is not a function #35

Open joehannouch opened 9 months ago

joehannouch commented 9 months ago

I've successfully integrated all my Get calls and got to the Post mutations now. I'm using NextJs 13.3.2 As soon as I make a call to the mutation I get an Unhandled Runtime Error

Unhandled Runtime Error TypeError: this[#client].defaultMutationOptions is not a function

image

A brief example of my mutation call: const addContentMutation = useContentControllerCreateContentMutation();

Help is appreciated

joehannouch commented 9 months ago

Apparently, it's an error with TenStack Query 5, everything works fine with V4. Will there ever be a V5 support update?

Thanks!

Shaddix commented 9 months ago

Oh, I missed v5 release! Thanks for mentioning that. I'll work on it coming week

Shaddix commented 9 months ago

version 15.10.1 should have support for Tanstack Query v5

scriptex commented 9 months ago

I also experience the same issue even though I updated to the latest (15.10.1) version. There are no issues with @tanstack/react-query v4 though.

Shaddix commented 8 months ago

calling mutations from example app works for me now. Do you still experience the issue? Could you share your OpenAPI definition?

scriptex commented 8 months ago

I am using these packages

"@tanstack/react-query": "5.8.4",
"@tanstack/react-query-devtools": "5.8.4",
"@tanstack/react-query-persist-client": "5.8.4",
"react-query-swagger": "15.10.3",

and the error I see when trying to run the TypeScript compiler (tsc) is the following

Property 'isLoading' does not exist on type 'UseMutationResult<unknown, Error, void, unknown>'

I am using it like this:

const { isLoading: isLoadingStart, mutate: handleStart } = useMutation(() =>
  someFn({
    arg1,
    arg2: {
      arg3: ''
    }
  })
);
ghost commented 6 months ago

what is the version excatly?

scriptex commented 6 months ago

what is the version excatly?

If this is related to my post above, I’ve already posted the versions 😄

o-alsalem commented 6 months ago

Yep, still have the same issue. Latest V5.

matiast02 commented 5 months ago

I have similar issue, I solved it using new sintax on V5, need to pass an Object for options. Try something like:

useMutation({ mutationFn: your_function_here })

Redthunder2 commented 5 months ago

I have similar issue, I solved it using new sintax on V5, need to pass an Object for options. Try something like:

useMutation({ mutationFn: your_function_here })

yeah this worked for me, thanks

Steven-zion commented 5 months ago

you need to have something like this:

const { mutate } = useMutation({ mutationFn: your_functionName, onSuccess: () => {}, });

Note the use of mutationFn

Steven-zion commented 5 months ago

Apparently, it's an error with TenStack Query 5, everything works fine with V4. Will there ever be a V5 support update?

Thanks!

close the the issue if its solved and mark the answer

Animeshsingh17 commented 3 months ago

I too had the same issue in v5 Did resolve this by keeping it as : const { mutate } = useMutation({ mutationFn: your_functionName, onSuccess: () => {}, });