T
tRPC

Why cannot I specify a mutation input with useQueryKey?

Why cannot I specify a mutation input with useQueryKey?

Ssnöw6/8/2023
It's supported with queries, but for some reason not with mutations. Why is this the case?
Ssnöw6/8/2023
The use-case is that I want global loading states for mutation with https://tanstack.com/query/v4/docs/react/reference/useIsMutating which I need a key for, hence the need for useQueryKey
Nnlucas6/8/2023
Mutations don’t typically have query keys, they’re not cached This is a react-query thing (I guess you get that though from the second link) Do we not expose isMutating via trpc.useContext? Many things that need query keys we do expose this way If not it might be because trpc.useMutation actually serves the same purpose in the context of trpc
Ssnöw6/8/2023
useContext only gives you the queries, so no luck there
Ssnöw6/8/2023
but I ended up here
Ssnöw6/8/2023
useIsMutating with the predicate where I can access the variables works, but no typesaftey 😦 I guess this could be wrapped to a custom TRPC wrapper of useIsMutating where the type is narrowed based on the mutationKey
Nnlucas6/8/2023
Yeah very possibly could be something we’ve missed Feel free to open a GitHub issue
Ssnöw6/8/2023
I used useIsMutating straight from react-query, so nothing missed 😄 but yep, this can be a feature request
Jjulius6/8/2023
iirc we have these in v11 Oh wait you wanna get the mutation key with input Nah
Ssnöw6/8/2023
that was the initial idea, but a custom useIsMutating with the mutation state typed in the predicate would be a better solution
Ssnöw6/8/2023
react-query hard sets the Mutation types to any, so a change would be required there as well
Ssnöw6/8/2023
I had something like this in mind:
Ssnöw6/8/2023
but the as step done by trpc anything specific I could check out?
RRiccardo10/11/2023
Hey, I need somthing you solved with useIsMutating but with isMutating client helper. I filed an issue https://github.com/trpc/trpc/issues/4889, do you mind bringing some more ideas/support there?

Looking for more? Join the community!

T
tRPC

Why cannot I specify a mutation input with useQueryKey?

Join Server
Recommended Posts
how to connect trpc server (t3 stack) from my external nextjs app?how to connect trpc server (t3 stack) from my external nextjs app?trpc.legacyRouterName.procedure "does not exist" on type CreateTRPCNextBase, runs anywayHave reached the end of a massive trpc 9 -> trpc 10 migration, executed using the official guide witNot getting legacy router ops in merged tRPC 9 routerFollowed the guide to merge my large tRPC 9 router with tRPC 10, but now I can't use useQuery or acccreateTRPCNext Type Error + useQuery Not DefinedI'm trying to use the conventions for `createTRPCNext ` from https://github.com/trpc/examples-next-pRead response headers on the clientIve been searching for a while trying to figure out how to access response headers on the client. FoIs it possible to access context in input?Hi, I have a validator that requires to get context of prisma in the `input`, Is it possible to get TRPCContextState not found in v10In our v9 app, we used TRPCContextState from internals to type out TRPC utils, importing it like `imRateLimiter for fastify tRPC routesHi, I would like to add Ratelimiter to a specific fastify trpc route, are there any solutions availaSubscriptionsare we able to send data over with subscriptions, to allow for full duplex communication ?Query tRPC the right wayIf you use graphql, you can precisely query what you exactly need and avoid over fetching, so you caHow does trpc subscription actively close/disconnect in the server?How do I actively disconnect my subscription?child router questionlet's say we have a monorepo, one server, two client apps (cat and dog). we make one appRouter, likHow to force SSL on projects using tRPC?Hello everyone, I'm working on a project that uses create-t3-app as boilerplate. My project is hosAWS Lambda / How to set Cookies inside ProceduresHow can I set and remove cookies similar to ctx.res.cookie(..) with Express when using the aws lambdMassive Type Errors on tRPC 10 Legacy Router against MergeRouterWe're trying to upgrade to tRPC 10 but I am running into a massive type clash when trying to merge rIs it possible to create 2 routers inside a single file?I am having an issue in which it is impossible to me to use a class instance within 2 routers. I triUse onError to change an application error into a TRPCError?I want to use the onError handler to change any instance of a custom application error into a TRPCErIncreasing Body 1mb limitHey, Im trying to build an application that allows sending of base64 encoded files to my next.js serNitro and tRPC in vercel-edgeHey there! I hope this is the right place to ask for help. I am trying to deploy an application witHow to retrieve and receive Bigint data to/from TRPC procedureNode: `v16.15.1` I'm trying to return an object which contains an `amount` property from one of my