Repository navigation
Input schemas defined with Zod does not use the inferred input type - #1189
Conversation
|
This pull request is being automatically deployed with Vercel (learn more). next-prisma-starter β ./examples/next-prisma-starterπ Inspect: https://vercel.com/trpc/next-prisma-starter/8vfHyasuzL89aYMMVCg48SqYw9VB www β ./wwwπ Inspect: https://vercel.com/trpc/www/8qKZKupHuN6BfRNSNUV6R4tVyBjr |
| export type ProcedureInputParserWithInputOutput<TInput, TParsedInput> = | ||
| ProcedureInputParserZodEsque<TInput, TParsedInput>; |
There was a problem hiding this comment.
This is a bit ugly -- needs to separate the ones where we can infer the input and output of the validator
| unknown extends TInput ? undefined : TInput, | ||
| unknown extends TParsedInput ? undefined : TParsedInput, |
There was a problem hiding this comment.
Ugly hack because this resolved as unknown on the ones without input
| public query<TPath extends string, TInput, TParsedInput, TOutput>( | ||
| path: TPath, | ||
| procedure: CreateProcedureWithInputOutputParser< | ||
| TContext, | ||
| TInput, | ||
| TParsedInput, | ||
| TOutput | ||
| >, | ||
| ): Router< | ||
| TInputContext, | ||
| TContext, | ||
| TQueries & | ||
| Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, | ||
| TMutations, | ||
| TSubscriptions, | ||
| TErrorShape | ||
| >; |
There was a problem hiding this comment.
I wish I didn't have to add these blocks
|
cc @mmkal - I merged this as it works, I'd love to see you having a stab at simplifying it if you feel inclined some day π |
|
Oh perfect! I was just trying to get this running locally so I could verify that it works and give some feedback here, but I couldn't figure out how to run it π I'll try this now! |
|
This pull request has been locked because it had no new activity for 30 days. If you think, this PR is still necessary, create a new one with the same branch. Thank you. |
Closes #1182
Will make something like making a REST-adapter a lot easier as one could do
param: z.union([z.string(), z.number()]).transform(v => Number(v))to handle query params.tl;dr Allows us to do this below: