TanStackT
TanStack3y ago
2 replies
faint-white

Default Mutation Fn ?

Hi, is there a way to make a default mutation Fn like the default query Fn for all mutations ? as i do not wish to keep writing the same fetch function for mutations too

i tried the below but doesn't work on useMutation


//in my global main.ts file when add the vue-query plugin  to my vue APP 

const queryClient = new QueryClient({
  defaultOptions: {}
})

queryClient.setMutationDefaults([], {
  mutationFn: defaultMutationFn
})

const vueQueryPluginOptions: VueQueryPluginOptions = {
  queryClient: queryClient,

  queryClientConfig: {
    defaultOptions: {
      queries: { queryFn: defaultQueryFn },
      mutations: {
        mutationFn: defaultMutationFn
      }
    }
  }
}

app.use(VueQueryPlugin, vueQueryPluginOptions)
app.mount('#app')
Was this page helpful?