tRPC

T

tRPC

Move Fast & Break Nothing. End-to-end typesafe APIs made easy.

Join

Cannot find namespace 'trpc'

I'm getting this error when trying to access <trpc.Provider ...>. Any idea what might be going on?

use tRPC for RPC calls instead of gRPC

Hi, I know that tRPC and gRPC are different things - despite the similar name. Nevertheless I would like to hear your opinion on using tRPC for things you would normally use gRPC for. What are possible use cases? What are the pros and cons....

tRPC caching vs Vercel dynamic edge caching

What is the difference, or improvements, on Vercel's dynamic edge caching? tRPC server caching works without it. What is the difference? I don't understand

Ignore Errors from batch calls

I have some of my routers throw helpful errors for the client to use in the error message object, but when one of those calls in a batch request, it causes the other calls to fail and never resolves. How do you get around that? I'd rather not add a nullable error field to all my results

Any way to view headers in middleware?

Middleware input doesn't seem to have it :/

How can I use a fork of trpc-next?

Hey there, I've made a fork of @trpc in order to fix an issue inside of @trpc/next. I can build it and manually use it in my code. However, I'm struggling to reference the package directly from github in yarn. I put the following in my package.json file: ``` "dependencies": { "@trpc/next": "skyriverbend/trpc#commit=9c0f4eb0896f06baeff789a841d4d9ae1b2a6f1b&workspace=@trpc/next",...

trying to cache api routes

Hello. I am using TRPC to make a site which integrates with a third party API. I need to add caching to some of my routes. ...

Prisma+TRPC monorepo

Hey, so we have a monorepo with 3 backend services and 3 frontend services. It looks like the following: - Content frontend - Content backend - Teacher backend - Teacher frontend...

calling api endpoints from within a trpc api endpoint?

Hey all. I have a series of api endpoints which may have to be reused across other api endpoints. I was wondering if this is possible? ```ts...

TRPC waiting until the query has completed

Hey. I've just found out about TRPC and I love it. However, I was wondering if there is a way to make it so the code below my query doesn't run until the query has completed, without having to make an external function or make use of a useeffect hook in order to use await? Is there a property of some sort which I can use to stop the page from rendering? The code below causes an infinite signIn loop due to the data not being there on the initial page render. But, I can't check if !guilds.data, because sometimes it wont return anything, due to an invalid token. Which means there is no good way to identify when to force a signIn for the user....

JSON Parse error Unexpected token R on react native

I keep getting this error on react native expo

trpc with headless cms

Hello, Is there any example with trpc and headless CMS or is there anypoint to use trpc for project that gets data from external source? For example existing api / headless CMS. And what would be the advantage over using for example react query and creating and getting data from api endpoint instead...

Is it possible to call a query from another query defined in the same router?

Say I have some code like the following: ``` t.router({ compute_all: t.procedure .query(async ({ctx, input})=>{...

Testing with React Testing Library

Hi! I am trying to test my
DestinationForm
DestinationForm
component using react testing library. My test is simply rendering the component: ```ts test('contains 2 input fields and a submit button', () => { const view = render(<DestinationForm />)...

Can I cache a response server-side?

For my project one of the trpc requests in my app works as an API Gateway to another API. I make a request to TRPC server, that makes a request with a secret API key to a 3rd party API, and returns the response to my user. In my case this 3rd party API has a rate limit that I'm going to be hitting soon....

Proxy TRPC server to another client

I've two TRPC servers, one essentially acts like a proxy, it validates auth and based on a specific property it forwards you to the destined server (with that one property removed). Now I have to write all those queries and mutation twice, is there a simpeler way to do this? Is there any way to bind a specific TRPC client to a server?...

Unexpected token

hi, kindly help me on this one

Throw custom TRPCError with specific cause

Hello everyone ! I'm trying to throw a custom TRPCError with a specific cause that i can differentiate from other trpc errors. My use case is to be able to catch error on client and display an error message if the error code is 'BAD_REQUEST' and a specific cause. After investigating i find that something like this should work in my mutation procedure: ``` throw new TRPCError({ message: 'Password changed too recently', code: 'BAD_REQUEST',...

Delay IsLoading....

i'm trying to delay a loading spinner from appearing if the api takes less than 200ms to get the data. I've tried a number of implementations and failed, can anyone help? ```js const { isLoading, isError, data } = trpc.ticketDomain.getByTicketId.useQuery(...

Clearing Cache

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....