Hi All! New to Prisma and GraphQL so I have what i...
# orm-help
c
Hi All! New to Prisma and GraphQL so I have what is likely a stupid question: Why do I need to define my data schema essentially twice - once in my
prisma.datamodel
file and again in my
schema.graphql
file? As per this example repo: https://github.com/prisma/prisma-examples/tree/master/node/graphql. Is it because the former is not really graphQL syntax? Also, why does the example repo define a separate graphQL server using graphql-yoga when the prisma playground “speaks” GraphQL and I can make graphQL queries against my prisma server/database.
n
Hey, the datamodel is essentially going to configure your database. The second is your public facing API schema that you would expose to the client.
👍 1
You might want to omit some fields from the public API schema for instance.
c
Gotcha. So the playground that the prisma server stands up is essentially a direct conversion of the prisma datamodel into a graphQL schema? Which is fine for development but may not be desirable for public use with additional complexity (e.g. permissions/authn/z) ?
n
Correct. You’d almost never want to expose the underlying Prisma API (while it’s authenticated - If you enable a secret key) it can be confusing to consume so the watered down API infront is often a great barrier
Plus you can take care of all the auth and side effects layer at the edge
c
Makes sense. Thanks for clarifying!
n
You might also want to check out this article https://www.prisma.io/blog/prisma-and-graphql-mfl5y2r7t49c/ @Craig 🙌
👍 1
j
Thanks @notrab. I had this exact confusion about the seeming duplication of gql serves and your distinction clears it up!