Query tRPC the right way
If you use graphql, you can precisely query what you exactly need and avoid over fetching, so you can do something like this:
how would you do that in tRPC?
do you have to implement an interface like this?
and what is if you want to query related stuff, like the user and its pets and from the pets you just want the ids but in other cases the names and ids
3 Replies
Trpc doesn’t offer anything like this directly, but as you’ve proposed it’s possible to do with plain typescript.
The problem of over fetching fields is generally not a problem for most apps though
@Nick Lucas so is my idea okay and common in tRPC?
Not really common, no, though I have thought it could be an interesting gap for a library to fill
You'll run into issues with varying output types based on input types. TS functions can do that, but tRPC can't since the input/output are isolated from each other