tRPC

T

tRPC

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

Join

conditional useQuery without input

How to use the enabled option for useQuery that doesn't has an input? ``` const { isError, error } = trpc.iam.logout.useQuery(undefined, { enabled: isEnabled,...

trpc query help

With trpc on the client side lets say I have a form component that creates a post and also a list component which displays the post on the same page, When I create a post, how do I make this list that displays the post refresh. I'm working with nextjs btw

change data from query

There is a page in which I make a query for a list of codes, and on that page you can also generate one, how do I change the data to update the list on the page without refetching?

How do I set header value from localStorage or Zustand in tRPC and React?

Hello, This is my tRPC client in my App.tsx: ```ts function App(): JSX.Element {...

how do you guys start a standalone trpc server?

settings up ts alone and express afterwards seems a bit of a hassle. wanna know if there is an easy way of doing it

TRPC completely broke

I have a project I haven't touched in only about a week, it was working and now every request over TRPC is broke. I have tried everything I can think of and I get responses like the attachment Here is part of my package.json ```json...

trpc + server actions

i wanted to use trpc without react query like with next's server actions but using a relative url throws error ```tsx import React from "react"; export default function ProjectList() {...
No description

Infer context from procedure after middleware

I'm using trpc version 10 on pnpm. I I have my handler functions in separate files from the routers themselves. I'm looking to type the context correctly based on the procedure the handler is used with....
Solution:
Okay I didn't come up with a direct solution, but I did solve it in a different way. Instead of just having the handler functions be in separated files. These -> .mutation(handlerFunc) I moved the whole creation of the procedure into seprate files. This way you can put the handler function directly into the .mutation call. This way the options (so also the context) are correctly inferred and the need to import the Context type becomes unnecessary. ```ts...

Why is Uint8Array converted in object when passed as input in `.mutate({ img: u8 })` - v11

I passed Uint8Array as input for file saving but when I log it on API (trpc function) it is shown as object of same array not array itself. Why is that?

Error: TRPCError: A non-domain error occurred

Been just randomly getting these. Has anyone else and do u know what it could be caused by?

GraphQL Mutation API Design

may be a dumb question. I'm new to graphql type api design coming from a rest controller api. Now often times with our rest api well have one service method to patch an object from a given patch. It seems like this may not be the way to go with graphql? Instead writing specific actions. Aka 'patchObjectName' instead of just 'patchObject' which takes a patch object. Is this correct design?

uploading image via trpc endpoint

Hello, is there any example for uploading an image to a trpc endpoint?

Unexpected end of JSON input error after upgrade to v11.0.0-rc.366 from rc.359

We updgraded from version 11.0.0-rc.359 to 11.0.0-rc.366 and now see BAD_REQUEST error being returned for mutations which worked fine before to upgrade. Stack: `TRPCError: Unexpected end of JSON input...

How can I get lint warnings for onSuccess/onError?

Maybe this isn't exactly a trpc question, but I'm thinking someone here would know. I would like to keep our project prepared for the transition to tRPC v.11 and the changes that come because of TanStack Query v.5.x. We have a lot of usage of onSuccess/onError in useQuery. So now I bumped tRPC to the latest 4.x (4.36.1) where they are marked as deprecated. I then realized that our lint setup does not warn for deprecations, so I added eslint-plugin-deprecation and enabled it per instructions. I then got a bunch of other deprecation warnings, so the plugin seems to be working, but nothing on these onSuccess / onError callbacks. Is this supposed to be working this way, or is there another way I could make it work?...

How can I add React to SST's TRPC example?

SST recently release an example on how to deploy TRCP to AWS, it's pretty cool! but I'm wondering how can I add react to it's client so I have both worlds: Repo: https://github.com/sst/ion/blob/dev/examples/aws-trpc/client.ts...
Solution:
who would've guessed that I could built it just reading the docs: https://github.com/gnllucena/trpc-sst...

tRPC useQuery with skipToken

I am trying to implement a useQuery which only happens once. I haven't been happy with setting enabled so something like enabled: !!foo as it'll still refetch, etc (and yes I know you can disable certain refetches, but that's not the goal here). I found a supported, type-safe solution on the tRPC docs (https://trpc.io/docs/client/react/disabling-queries).
But... following their example nearly identically doesn't work for me....
Solution:
Nevermind, this idiot wasn't on tRPC v11. Just did the upgrade, was pretty painless. Shoutout to the tRPC team. I'll leave this up incase anyone else experiences a similar issue and goes down the rabbithole. UPGRADE TO V11 TO GET SKIPTOKEN TO WORK!...

Error calling middleware

I'm getting an error trying to test out some pretty basic middleware. This is my code ```ts export const createContext = ({ req,...

Mutation returning a long URL is being cut off

I have an authentication URL for an oauth2 provider that returns a long URL due to scopes being added. The server returns a cut-off version of it to the client. Not sure why.

TS7056: The inferred type of this node exceeds the maximum length the compiler will serialize.

I have tsc complaining about my root app router type being too large when using --declarations. There was a ticket from 2022 about this, but it seems to have been closed as solved. There are some Zod tickets about this too, but unfortunately they don't provide solutions that are viable (e.g. disabling --declaration is not viable for me.) It seems like this is caused by having a large app router, where "large" means it has a bunch of endpoints, and the total combination of those endpoints' input and output validators (using Zod schemas) go above a certain threshold. I can solve it by strategically adding explicit types to some of the query/mutation handler function definitions, but it's a bit odd....