Hello, could someone help me clarify a concept?: ...
# prisma-client
h
Hello, could someone help me clarify a concept?: I am trying to use GraphQL + Prisma with a code-first approach. My goal is having a single source of truth for my models and types. I'm opting for the Nexus approach, but in the examples provided by Prisma, it seems there are still 2 sources for model data: the
schema.prisma
file and the nexus code which generates the
schema.graphql
file. How do I make Prisma use the file generated by Nexus to generate the Client and push changes to the DB? Thanks for the help.
r
@Hector 👋 There would always be 2 sources in this case. One being your
schema.prisma
and the other being Nexus resolvers. The resolvers will generate a
schema.graphql
file that will be needed to serve your GraphQL API. One way around this is autogenerating resolvers using plugins like these to generate your
schema.graphql
from your
schema.prisma
. https://paljs.com/generator/nexus https://typegraphql.com/docs/prisma.html
How do I make Prisma use the file generated by Nexus to generate the Client and push changes to the DB?
This is not possible. It’s only the other way around, i.e. GraphQL schema from Prisma schema and that’s the way it should be.
👍 1
h
Thanks for the help! I was precisely looking at autogenerating base resolvers from the Prisma schema, this is great!
💯 1