tmy03
tmy037mo ago

TypeError: queryClient.getMutationDefaults is not a function (it is undefined)

Hi! There's not much code to show here, as I'm really not sure where the error actually occurs. In my React component I have: const { mutate } = api.story.create.useMutation(); This gives the following error: ERROR TypeError: queryClient.getMutationDefaults is not a function (it is undefined) Has anyone experienced the same? I can't find any good results on Google, so I guess it's not a typical issue. The is the first mutation I've tried to do. GET queries are working just fine.
1 Reply
tmy03
tmy037mo ago
The error happens in here trpc/packages/react-query/src/shared/hooks/createHooksInternal.tsx, line 347 on queryClient.getMutationDefaults:
function useMutation(
// FIXME: this should only be a tuple path in next major
path: string | [string],
opts?: UseTRPCMutationOptions<unknown, TError, unknown, unknown>,
): UseTRPCMutationResult<unknown, TError, unknown, unknown> {
const { client } = useContext();
const queryClient = useQueryClient({ context: ReactQueryContext });
const actualPath = Array.isArray(path) ? path[0] : path;

const defaultOpts = queryClient.getMutationDefaults([
actualPath.split('.'),
]);
function useMutation(
// FIXME: this should only be a tuple path in next major
path: string | [string],
opts?: UseTRPCMutationOptions<unknown, TError, unknown, unknown>,
): UseTRPCMutationResult<unknown, TError, unknown, unknown> {
const { client } = useContext();
const queryClient = useQueryClient({ context: ReactQueryContext });
const actualPath = Array.isArray(path) ? path[0] : path;

const defaultOpts = queryClient.getMutationDefaults([
actualPath.split('.'),
]);
I'm using tRPC version 10.43.6 Nevermind. I was using a @tanstack/react-query version 5. Downgraded to 4 and everything works.
More Posts
useQuery never returning or hitting APII have something off in my configuration, i copied most of the files from the `❯ npm create t3-app@lType 'QueryClient' is missing the following properties from type 'QueryClient': queryCache, mutationI am trying to setup a new project and doing my first client side query and getting this error: ```trpc mutation call stuckI have an issue with a simple mutation procedure: `getPublicUser: publicProcedure .input(z.objeCreate client based on OpenAPIHi! I am running a golang server with an openapi spec and would love to use trpc client in my fronteTRPC with react query, getting error twice?When i am try to show TRPC error in the client side with react-query, i am getting error twice from Error building create-t3-app: Page couldn't be rendered statically because it used `cookies`I get the following error when building create-t3-app: ``` TRPCClientError: Dynamic server usage: PaCompressing parts of query/mutation inputHi, I'm using trpc with the proxyclient for typesafety but recently hit an obstacle where some strin`useSuspenseQuery` still runs a fetch on SSR even when setting `ssr: false` in the api configBeside double-fetching, this causes issues during rendering if you have auth on your routes as the SUnsubscription callback triggering immediatelyHey! I am currently using Bun that's queried via a Vue application. For some reason the unsubscribeMultiple optimistic updates and old data from refetchesHi all, I'm new to tRPC and React Query and I'm just trying to get my head around what exactly I'm d