citrinitas
citrinitas
PPrisma
Created by citrinitas on 6/30/2024 in #help-and-questions
Representing a User with sub-roles
Zenstack apparently supports this: https://zenstack.dev/docs/next/guides/polymorphism
3 replies
PPrisma
Created by citrinitas on 6/30/2024 in #help-and-questions
Representing a User with sub-roles
Nevermind, if anyone ever considers this the issue is that prisma doesn't support polymorphism. I ended up doing this in my user model: @@unique([staffId, customertId]) to ensure user can be only staff or customer. And then in my sdl: union RoleDetails = Staff | Customer union type. So that I can return it in the resolver properly: return { ...user, roleDetails: user.staff || user.customer };
3 replies