Could someone please tell me where I can find the ...
# orm-help
j
Could someone please tell me where I can find the code from prisma, which auto generates the graphql schema from a database?
n
Do you mean the GraphQL API, or the datamodel (introspection)?
j
With
graphql get-schema
I can download the schema from the endpoint, I would like to study the code which generates this schema based on the database.
n
Got it! The code resides here: https://github.com/prismagraphql/prisma/tree/master/server It's probably easiest to step through the code when executing a test. Here are instructions for setting up your dev environment to do so: https://github.com/SHASHANK-PRO-05/prisma/blob/11372ff7eb18cca9c4e2c186c75c12898ae85c74/server/CONTRIBUTING.md
👍 1
j
Thank you very much! Amazing support 🙂
n
You're welcome! 🙂 Love to help out in the community
j
So if I understood this correctly, the code in
/server/servers/api/src/main/scala/com/prisma/api/schema
is responsible for creating a database specific schema, right?
n
Yup. Specifically, the SchemaBuilder: https://github.com/prismagraphql/prisma/blob/master/server/servers/api/src/main/scala/com/prisma/api/schema/SchemaBuilder.scala I am curious what you want to achieve, can you share more about this?
j
All right, I thought so, but I don't know Scala, so I wasn't sure. I need to write (Java) software that creates the GraphlQL schema for an existing database. In principle almost exactly like the schema you get with "graphlql get-schema" from the Prisma application, but it should only contain requests and should generally not be as extensive as with Prisma. So I wanted to look at the code of Prisma to see how exactly the database (i.e. relationships, attributes etc.) are mapped in the schema. I would also like to use jOOQ for modelling the database in Java and create with the help of these jOOQ classes the graphQL schema.
n
Interesting. What speaks against actually using Prisma? Are you missing something specifically?
j
Prisma works great, but I only need a really small part of it, so it would be a good idea to do it myself. Another question, I've looked at the schema generation now and in principle the schema is generated from the file
datamodel.graphql
, right? So the input for the schema generator is the data model and the complete schema is created from this file?
👍 1