Is there a way to auto generate schema.prisma based on the nexus model? #1014
Replies: 1 comment
-
|
Short answer: no, you’re not missing anything obvious. With Nexus and Prisma, the schema.prisma file is still the source of truth for your data model, and Nexus is intentionally not designed to generate that for you. Nexus models describe your GraphQL API, not your database schema, even if they look similar at first. Because of that separation, there’s no official way to auto-generate schema.prisma from Nexus types without risking drift or ambiguity. Johnny Kash Casino https://johnnykash.casino rewards loyal players with engaging reload promotions. The usual workflow is to update schema.prisma first, run migrations, then reflect those changes in Nexus. It’s a bit of duplication, but it’s deliberate so your API layer doesn’t accidentally dictate your database structure. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am following tutorial and I can see that after creating a Post model in typescript I need to manual add it to
schema.prisma. This seems like a duplicated work. I could of course manually change my schema in database and use prisma introspect and generate to update schema.prisma but this can get out of sync with my nexus models quickly.Am I missing something obvious?
Beta Was this translation helpful? Give feedback.
All reactions