T
tRPC

useContext not Invalidating

useContext not Invalidating

TTypedef8/10/2023
What are the possible mistakes if useContext wont invalidate when doing the following:
const utils = trpc.useContext();
const user = trpc.user.getUser.useQuery();
const updateUser = trpc.user.updateUser.useMutation({
onSuccess: () => {
utils.user.getUser.invalidate();
}
});
const utils = trpc.useContext();
const user = trpc.user.getUser.useQuery();
const updateUser = trpc.user.updateUser.useMutation({
onSuccess: () => {
utils.user.getUser.invalidate();
}
});
Used to work before but stopped working when I turned my entire repo to turborepo.
AKAlex / KATT šŸ±8/11/2023
could be that you should await the invalidate to the mutation stays loading until invalidation is complete
const updateUser = trpc.user.updateUser.useMutation({
onSuccess: async () => {
await utils.user.getUser.invalidate();
}
});
const updateUser = trpc.user.updateUser.useMutation({
onSuccess: async () => {
await utils.user.getUser.invalidate();
}
});
`
TTypedef8/18/2023
Still doesnt work hmm but if I do user.refetch() it works I can confirm that it calls onSuccess after but not sending a query at all Any ideas @alexkatt Still not working ..
AKAlex / KATT šŸ±8/18/2023
TTypedef8/18/2023
Hmm, I really dont want to invalidate eveything on any onSuccess mutations Any ideas on why it doesnt work?
AKAlex / KATT šŸ±8/19/2023
Idk maybe you have to react query providers or something
TTypedef9/1/2023
im using nextjs, my app is wrapped with withTrpc() Okay weird, I tried doing an override:
overrides: {
useMutation: {
async onSuccess(opts) {
await opts.originalFn();
await opts.queryClient.invalidateQueries();
},
},
},
overrides: {
useMutation: {
async onSuccess(opts) {
await opts.originalFn();
await opts.queryClient.invalidateQueries();
},
},
},
it invalidated all the cached queries. Still lost why it wont invalidte with const utils = trpc.useContext();

Looking for more? Join the community!

T
tRPC

useContext not Invalidating

Join Server
Recommended Posts
Deduping is broken, but is being batchedHi all, We're using TRPC for our React Native app, while doing some testing, I saw in my server logQuestion about trpc revalidation methodalright I have a question, why can tRPC detect changes from the DB and refetch. but when I mutate thHow can I enable experimental Suspense on NextJSO have a project with trpc (v.10^) and nextjs 13, and I wanna test the suspense query, but not show Examples of Vitest with React Testing LibraryDoes anyone have examples of how to mock data from tRPC procedure calls? I have client components thHow to refetch based on different eventI have a procedure that fetches all products, I have another one that deletes a project given it's IDockerizing in TRPCHi guys, I am developing a Next app with TRPC subscriptions/websockets and am running into issues trJest set cookie with callerIm trying to test a protectedProcedure, which validates a cookie , if the cookie isnt present, it reUseQuery with no Input but query optionsI have a trpc protected procedure that does not take any input. First argument of use query is input`useQuery` in client componentsI have a very simple app with a single page configured to use SSR. The component that the page rendeHow to refetch data for a query when a mutation is performed in a different component?To give a quick explanation of what Iā€™m trying to do, Iā€™m creating a system where a user can requestTrying to lazy init "createTRPCProxyClient"I'm trying to wrap `createTRPCProxyClient`, but having trouble with the generic. Maybe I'm just a TSGet query parameters in middlewareHi! I'm looking to perform authorization inside of middleware and I'm wondering how I can access thetrpc middlewarecan you help me to catch all Response Codes from fetch called via trpc #ā“-helpMultiple React Providers?I'm trying to have multiple providers in the same react (they can't be merged w/ virtual routing). IcreateCaller from API NextJS (Pages Directory)Hi, i want to call the procedure I was created in nextJS API.. and I already look at the documentatiWhy transformer: superjson breaks the POST ?With all the GET request I do there seem to be no error, but as soon as I try sending a POST requesttrpc receiving undefinedHello, I am having a few problems with one of my TRPC endpoints not recieving the data sent through How do you invalidate queries in nextjs app?`experimental_createTRPCNextAppDirClient` don't seems to have the useContext so how do i invalidate Do tracked properties still work when using useSuspenseQuery?From the React Query docs: ```By default, access to properties will be tracked, and the component wiProcedure return types are getting inferred as anyHi, I just created a prisma + trpc backend which uses prisma-trpc-generator to generate trpc routers