How to refetch based on different event
I have a procedure that fetches all products, I have another one that deletes a project given it's ID, these two are used on the same page, how can tell tRPC to rerun the allProducts request when a delete happens.
currently I need to refresh to see the product get deleted, in case that's not what's supposed to happen please tell me.
I am using the pages router and tRPC v10...
Dockerizing in TRPC
Hi guys, I am developing a Next app with TRPC subscriptions/websockets and am running into issues trying to dockerize it. I took a look at the example project at https://github.com/trpc/examples-next-prisma-websockets-starter and saw that the docker-compose only dockerized the database and not the nextjs app. I was wondering if there was a reason for this.
My app works fine locally but as soon as I try to run it in a docker container, I get various errors like the websocket connection closing a few seconds into using the app.
Here's some excerpts of the errors...
Jest set cookie with caller
Im trying to test a protectedProcedure, which validates a cookie , if the cookie isnt present, it returns 401.
Im using caller to call the endpoints inside jest tests, how i can set mock cookie for these tests?...
UseQuery with no Input but query options
I have a trpc protected procedure that does not take any input. First argument of use query is input .If i dont provide input it gets mad says type bla bla is not assignable to type void. I came across a workaround for using undefined in place of empty input . is there any better approach ?
...
const { data} = trpc.cart.getUserCart.useQuery(undefined, { enabled: !!UserSession?.user?.id });
const { data} = trpc.cart.getUserCart.useQuery(undefined, { enabled: !!UserSession?.user?.id });
`useQuery` in client components
I have a very simple app with a single page configured to use SSR. The component that the page renders requests data using the tRPC client and
useQuery
function. I modified the component to be a client component by adding use client
on top of the file.
The result I expected to see was app fetching the component from the server and loading data asynchronously from the client.
Instead, the server's response is delayed until the data is loaded and the browser renders component with the data already loaded.
Is it possible to use the combination of tRPC + SSR + use client
? If so, wouldn't the code below result in the behavior I was expecting?...How 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 request to join a group and then the admins can accept or decline the request. I've tried following the docs for invalidating a single query but it seems to not be working in my case.
Component A is fetching the request status on the user side through a useQuery on one of my tRPC procedures.
Component A (checking request status on user side)...
Trying to lazy init "createTRPCProxyClient"
I'm trying to wrap
createTRPCProxyClient
, but having trouble with the generic. Maybe I'm just a TS idiot, but I thought something like this would work:
```
export function createTRPC<X extends AnyRouter>(options) {
return createTRPCProxyClient<X>({ links: [/** link stuff */] })
}...Get query parameters in middleware
Hi! I'm looking to perform authorization inside of middleware and I'm wondering how I can access the parameters that the user queried inside of the middleware?
For example, let's say a user requested to look at Workout routine ID 532 in an API call. How would I be able to access the workout ID inside of middleware? I have their userID within CTX but no way to get the url path
Thanks!...
Multiple React Providers?
I'm trying to have multiple providers in the same react (they can't be merged w/ virtual routing). I'm trying to follow the example in this PR, but I can't get it working. https://github.com/trpc/trpc/pull/3049
No matter what I try, I get the error
No QueryClient Set
even though there is one and it's setup just like the test.
Anyone have success with this?...createCaller from API NextJS (Pages Directory)
Hi, i want to call the procedure I was created in nextJS API.. and I already look at the documentation but I'm getting error like this šš»
Argument of type '{}' is not assignable to parameter of type '{ session: Session | null; prisma: PrismaClient<Prisma.PrismaClientOptions, never, DefaultArgs>; }'.
how to fix it?...

Why 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 request, i get the following :
```
"message": "[\n {\n "code": "invalid_type",\n "expected": "object",\n "received": "undefined",\n "path": [],\n "message": "Required"\n }\n]",
"code": -32600,...
trpc receiving undefined
Hello, I am having a few problems with one of my TRPC endpoints not recieving the data sent through a webhook body
```ts
export const voteRouter = createTRPCRouter({
voteCreate: publicProcedure
.input(...

How do you invalidate queries in nextjs app?
experimental_createTRPCNextAppDirClient
don't seems to have the useContext so how do i invalidate queries?Do tracked properties still work when using useSuspenseQuery?
From the React Query docs:
...
By default, access to properties will be tracked, and the component will only re-render when one of the tracked properties change.
By default, access to properties will be tracked, and the component will only re-render when one of the tracked properties change.
Procedure return types are getting inferred as any
Hi, I just created a prisma + trpc backend which uses prisma-trpc-generator to generate trpc routers from the prisma schema.
I noticed that while procedure parameters are correctly typed the return type is not getting inferred.
This is not a monorepo-related issue since I moved my client to the server directory and the return types are inferred as
TProcedure["_def"]["_config"]["transformer"] extends DefaultDataTransformer ? Serialize<TProcedure["_def"]["_output_out"]> : TProcedure["_def"]["_output_out"]
, a type that despite not being any behaves exactly like any, not providing any type-checks or autocompletion.
...Hey š
I'm looking to use tRPC with app-router specifically with this setup;
- My pages are RSC, and I want to fetch the data there using trpc route / .query or .fetch (page.tsx), cached
- My forms are "client side" I want to mutate using react-query on client side and manually invalidate RSC fetchers above ^ upon mutations
...
what is "use" keyword
```ts
const baseProcedure = t.procedure
.input(z.object({ townName: z.string() }))
.use((opts) => {
const input = opts.input;...
How to Type a Middleware factory?
Lemme first show you what I want, so you can get the gist of it. (Consider me less experienced in typescript)
```ts
publicProcedure
.input(z.object({ test: z.boolean() }))...
