Help with inferring output
I have the following return and I want to infer the types of a single item, before I added the include bit the code worked, but now it gives me an error, how to set it up correctly?
5 Replies
Prisma won't properly infer types with a condition in select input
You better create a separate prisma findMany for each group type
I thought this might be the problem but even if I just have a price: true the error is the same, I dont need it to tell me what pricing is there, I just dont want it sent to the user, it pretty much just have every price as number | undefined which is fine by me
the issue is that I need to turn it to a singular item from the array and its not working when having that include, with or without the coditions
Does this help? Prisma has some tools to infer the types of select, include, etc..., I also had a similar use case.
Prisma
Advanced type safety (Reference)
Prisma Client provides full type safety for queries, even for partial queries or included relations. This page explains how to leverage the generated types and utilities.
Sorry, forgot to address the conditionals. I found a bug report here
GitHub
Conditional select and include not inferring expected type · Issue...
Bug description Our backend API has routes where we can optionally perform what the include API does. For example fetch user and optionally include posts written by this user. I expect the inferred...