T
tRPC

Clearing Cache

Clearing Cache

Zzeph166511/24/2022
How do I clear the queryCache for a particular query using the trpc context? If that's not possible, how can I do that using queryClient?
queryClient.getQueryCache().clear()
queryClient.getQueryCache().clear()
I've tried the above but it clears the entire cache. I just want to clear the cache of particular key. Thank you!
UUUnknown User11/24/2022
2 Messages Not Public
Sign In & Join Server To View
Zzeph166511/24/2022
Oh I forgot to mention that I would like to clear the cache for an infinite query such that when the user queries for it again, it starts from scratch e.g. just the first 5 results. But when I used invalidate queries, it seems to refetch all the results that were initially loaded. i.e. if the user loaded 15 results, the refetch would refetch all 15 results which is not what I wanted.
UUUnknown User11/24/2022
Message Not Public
Sign In & Join Server To View
Zzeph166511/24/2022
I did the following:
const utils = trpc.useContext()
utils.liked_place.infiniteList.invalidate()
const utils = trpc.useContext()
utils.liked_place.infiniteList.invalidate()
UUUnknown User11/24/2022
Message Not Public
Sign In & Join Server To View
Zzeph166511/24/2022
I see! Let me give that a shot! Thank you🤗 Actually, do I have to be more granular? I do want to clear the cache for all liked_place infinite queries. currently my keys look like this: [["liked_place","infiniteList"],{"folderId":"7218f699-78a8-4524-b15e-9a6c13e80af5","limit":5,"userId":"13dbca38-063d-4df7-bd1f-72908d1332fe"}] and the user has several folders. So I just want to clear the entire cache for [liked_place, infinitelist]
UUUnknown User11/24/2022
Message Not Public
Sign In & Join Server To View
Zzeph166511/24/2022
oh, I actually want to invalidate the entire liked_place cache, not just the first 5.
UUUnknown User11/24/2022
2 Messages Not Public
Sign In & Join Server To View
Zzeph166511/24/2022
Alright! Thanks so much for your patience and help!(: Really appreciate it!

Looking for more? Join the community!

T
tRPC

Clearing Cache

Join Server
Recommended Posts
context at times emptyam new to trpc. i am usin iron-session with nextjs and its awesome. am forwarding the context. but sTRPC Testing Wrapper - Unit Testing components that contain a query (Not testing the query it self)This is my wrapper reference from trpc: https://github.com/WeirdoGit/NewGitRepo/blob/162cd9317c0e978query and mutate promise on nextI've followed the guide "Usage with Next.js" and now I only have the `useQuery` and use `useMutationtesting a trpc hooki'm brand new to testing and need some help with writing a test for a hook that is returning an objeCAS AuthenticationSo long story short. My University is using CAS as authentication provider. I was thinking that I coDifference in type inference for vanilla client?Hello, querying an endpoint with the vanilla tRPC client but at runtime the actual result isn't the Zod Error MiddlewareHey lovely people. At Cal.com we make heavy use of `zod` for data validation. I was wondering if theclear cookie onErrorI'd like to clear a cookie (in nextjs) when a 403 error happens. I've been looking at the global errRequest context from getServerSidePropsThe docs of tRPC context https://trpc.io/docs/v10/context ``` export async function createContext(oAuth with passport.jsEvening all, Has anyone successfully setup trpc with passport.js for auth?Object keeps getting overwrittenI feel like i'm missing something fundamental here. when I add a new entry into object ``b`` it resAccessToken for API callsWhat would be the best approach to pass the AccessToken from NextAuth Session to the Http Client whiRequest or Response Specification Definition DocumentI am developing a backend service using trpc, but I need to dispatch trpc in another programming lanabortOnUnmount config errorI'm encountering an error when passing abortOnUnmount saying that it does not exist as a possible pazustand + trpc (basic data fetching)im trying to use zustand with trpc, but having trouble setting some data to global state. What am i TypeError Cannot destructure property 'abortOnUnmount' of 'useContext(...)' as it is null.Zero Clue what is error mean exactly....First time learning trpc really good tool. help with setting cookies on front end.Hello how do you use tRPC to make a cookie and send it to the front end. or is there any other methoHow do we add settings in each query like before?Since the new update, bee super confused. I used to do this, and can't recreate it now. ``` const Handling error globallyAccording to the docs on errors https://trpc.io/docs/v10/error-handling I should get such error objecant access trpc endpoints via the browseri'm converting some express endpoints to trpc, and I cant figure out how to access my endpoints via