Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inferQueryResponse helper for tRPC #28

Merged
merged 2 commits into from
Jun 23, 2022
Merged

Conversation

vitorwlima
Copy link
Contributor

Added a helper to infer types from queries in tRPC. It is a really important one that always needs to be googled because the syntax is really difficult. I believe it is really helpful to have this in the template.

Example:
Definition: https://github.com/TheoBr/roundest-mon/blob/e2834b689941df2c61b5acb9816f675437c92df9/src/pages/api/trpc/%5Btrpc%5D.ts#L11
Implementation: https://github.com/TheoBr/roundest-mon/blob/827d89463e1fc6edb7bbb5eb814fde67f6c36381/src/pages/index.tsx#L88

@vitorwlima
Copy link
Contributor Author

image

@nexxeln
Copy link
Member

nexxeln commented Jun 22, 2022

This looks cool! I think it's definitely less used though. I personally have never used it, including it by default feels wrong to me because someone might never use it and its just unused code at the end. Does that make sense?

Would love to hear other people's thoughts on this as well.

@c-ehrlich
Copy link
Member

I have used this before, saw it in Theo's video and found it useful immediately. In a perfect world this would be something that gets added to tRPC in some way, instead of having to put it in the starter where a keeping the codebase small is desireable.

For the time being while this is not the case, I'm not sure if it's better to include or not.

@juliusmarminge
Copy link
Member

juliusmarminge commented Jun 22, 2022

Maybe just leaving a commented link to where you can find them?
https://trpc.io/docs/infer-types#inference-helpers

p.s. I think this is a util that I usually put in my utils/trpc.ts
CleanShot 2022-06-22 at 10 21 25

@nexxeln
Copy link
Member

nexxeln commented Jun 22, 2022

Maybe just leaving a commented link to where you can find them? https://trpc.io/docs/infer-types#inference-helpers

p.s. I think this is a util that I usually put in my utils/trpc.ts CleanShot 2022-06-22 at 10 21 25

I like this. @vitorwlima I think this is the way to go.

@vitorwlima
Copy link
Contributor Author

I agree, this way it helps but it never leaves unused code. I'll make the change to the PR.

@nexxeln
Copy link
Member

nexxeln commented Jun 23, 2022

Thanks! Looks good.

@nexxeln nexxeln merged commit c0cde2d into t3-oss:main Jun 23, 2022
devvianto605 pushed a commit to devvianto605/create-devviantex-nextjs-app-deprecated that referenced this pull request Jun 9, 2024
Add inferQueryResponse helper for tRPC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants