react-query-swagger icon indicating copy to clipboard operation
react-query-swagger copied to clipboard

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

Open joehannouch opened this issue 1 year ago • 15 comments

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 avatar Oct 18 '23 18:10 joehannouch

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

Thanks!

joehannouch avatar Oct 20 '23 23:10 joehannouch

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

Shaddix avatar Oct 21 '23 06:10 Shaddix

version 15.10.1 should have support for Tanstack Query v5

Shaddix avatar Oct 22 '23 07:10 Shaddix

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.

scriptex avatar Oct 24 '23 11:10 scriptex

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

Shaddix avatar Nov 11 '23 16:11 Shaddix

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: ''
    }
  })
);

scriptex avatar Nov 20 '23 07:11 scriptex

what is the version excatly?

ghost avatar Jan 20 '24 08:01 ghost

what is the version excatly?

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

scriptex avatar Jan 20 '24 09:01 scriptex

Yep, still have the same issue. Latest V5.

o-alsalem avatar Jan 23 '24 13:01 o-alsalem

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

matiast02 avatar Jan 30 '24 14:01 matiast02

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

Redthunder2 avatar Feb 07 '24 07:02 Redthunder2

you need to have something like this:

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

Note the use of mutationFn

Steven-zion avatar Feb 07 '24 10:02 Steven-zion

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

Steven-zion avatar Feb 07 '24 10:02 Steven-zion

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

Animeshsingh17 avatar Apr 12 '24 09:04 Animeshsingh17

Hi everyone......in React Query V5 should work.....the problem is the availability of query client....this have worked for me!

export const useSignInMutation = () => useMutation({mutationFn: AuthApi.signIn}, queryClient);

samug0 avatar Sep 19 '24 15:09 samug0

I am using Vue one @tanstack/vue-query I have latest packages:

     "@tanstack/vue-query": "^5.59.13",

i get this error:

Uncaught (in promise) TypeError: client.defaultQueryOptions is not a function
    at ComputedRefImpl.fn (chunk-XV6XIJVG.js?v=897b9526:3988:30)
    at refreshComputed (chunk-TF6X5W6F.js?v=897b9526:634:29)
    at get value (chunk-TF6X5W6F.js?v=897b9526:1825:5)
    at useBaseQuery (chunk-XV6XIJVG.js?v=897b9526:3992:58)
    at useQuery (chunk-XV6XIJVG.js?v=897b9526:4082:10)
    at useUpload (user.ts:8:10)
    at setup (UserDetails.vue:56:26)
    at callWithErrorHandling (chunk-TF6X5W6F.js?v=897b9526:2260:19)
    at setupStatefulComponent (chunk-TF6X5W6F.js?v=897b9526:9943:25)
    at setupComponent (chunk-TF6X5W6F.js?v=897b9526:9904:36)

main.ts:

app.use(VueQueryPlugin, {
  queryClientConfig: {
    defaultOptions: {
      queries: {
        refetchOnWindowFocus: false,
        retry: 0
      }
    }
  }
});

Ge6ben avatar Oct 19 '24 08:10 Ge6ben

I solved my downgrade the version to : "@tanstack/vue-query": "^4.37.1", I hope to fix this issue I also created issue here https://github.com/TanStack/query/issues/8198

Ge6ben avatar Oct 19 '24 08:10 Ge6ben