PinkiePie
PinkiePie
Explore posts from servers
TtRPC
Created by thomasplayschess on 9/13/2023 in #❓-help
Wrapping useQuery into a custom hook
does anybody know how to solve it with up-to-date trpc?
66 replies
PPrisma
Created by PinkiePie on 5/19/2024 in #help-and-questions
how to return an empty array instead of null
@Nurul (Prisma) yep, i use composite types, so I had to do the thing you proposed for every model which uses my type. it works, and it achieved the desired outcome, but it feels like a dirty workaround anyway. prisma doesn't have optional lists. Why then it returns me a null instead of an empty array? That's a misleading DX. Prisma should either allow optional lists in the schema, so m Int[]? will produce number[] | null type, and force me to check the array before accessing it, or it should return an empty array by default instead of null. Currently, the field m can be nullable on the database level (for example if I pass it undefined during create operation, but the generated TS type shows like it can be never optional. So, I will have to add the check if the field m everywhere, but the devs after me would try to remove it as "unnecessary" check (type in TS and schema clearly shows that it's a mandatory field). So, your solution works as a temporary fix, but for sure it's something wrong on Prisma's side. Either return [] by default instead of null, or allow us to mark lists as optional in schema, so we will generate correct TS types
5 replies