Pattern for Prisma Generated Types are not Serializable
I'm looking for a pattern that will help me deal with the types Prisma generates that are not serializable.
The primary culprit is columns with a
The is either at build time using
Example Prisma model that causes this problem:
React Page component that causes the error:
Prisma can't generate the DateTime type as a date string: https://github.com/prisma/prisma/discussions/5522
I can just create duplicate types that mirror the Prisma types but with
My goal:
Be able to run a prisma query(from GetServerSideProps or GetStaticProps) and pass the resulting value directly to my page props using the types generated from my schema.
The primary culprit is columns with a
DateTime type which translates to the Date type on a TypeScript type.The is either at build time using
GetStaticProps or run time using GetServerSideProps. And the error will be Example Prisma model that causes this problem:
React Page component that causes the error:
Prisma can't generate the DateTime type as a date string: https://github.com/prisma/prisma/discussions/5522
I can just create duplicate types that mirror the Prisma types but with
Date fields replaced with String fields. This really sucks. I don't want to manage multiple copies of types. My goal:
Be able to run a prisma query(from GetServerSideProps or GetStaticProps) and pass the resulting value directly to my page props using the types generated from my schema.