Replies: 1 comment
-
Never mind I am blind. #1199 answers it. My bad. Seems like best practice is to use code gen tools on the frontend. It feels a bit more odd on a mono repo , but better keep what is on the server on the server. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This library is fantastic by the way, both in terms of usability, extensibility and the code quality within this repository. This is out of this world.
I try as much to follow Domain Driven Design. I have an Nx monorepo where I use prisma and TypeGraphql to generate everything I need. I'm not sure if I am being out of this world by doing this, but since I have an Nx monorepo, what I do is use the generated models by applying the browser shim. Because at the end of the day, my frontend code is consuming those models so that way I have only one model to rule them all and it is the prisma schema with anything custom added by TypeGraphql.
The thing is, I use the DateTime prisma attribute and then the class generated will have the Date type. Then, on the frontend, I query my API and it returns dates as strings. When I want to consume that within my components, since I use the generated model type, it sees it as a Date, but it is a string
example of a model:
What would be the best way to reuse models on the frontend, but declare Dates to be string (or better, have them be transformed to JavaScript date objects)? Must I redeclare myself those properties using Typescript myself? Must I manually transform this data myself when fetching. I would say the same applies to enums and what not.
Beta Was this translation helpful? Give feedback.
All reactions