cssetian
cssetian10mo ago

Is there a way to configure a trpc router to require an output() schema to be specified?

I would like to require the output() schema to be specified on all the queries and mutations in my project through some sort of typecheck or linting rule, as a way of documenting API though code and making our api specifications more explicit. Is there any way through router config or through linting config to force this to be specified? I am unfortunately not familiar with writing custom eslint rules so I don't know how to approach it if I wanted to write a custom eslint rule myself
2 Replies
Alex DB
Alex DB3mo ago
+1 for a way to enfore having an output schema defined
wleistra
wleistra3mo ago
I initially thought this was also a great idea at first, then i had a route procedure returning A LOT of data and the output (zod) validation punishment was so hard that we ran out of memory on our node instance and had in other cases over 30 seconds performance penalty... Maybe it was an exceptional case we ran into. But something to consider.

Did you find this page helpful?