Question: If I define a graphql schema at application server, different from or independent of Prisma datamodel, do I lose all the benefits of generated models, and
graphqlgen generated resolvers?
I understand that this is more of a confusion from me, than a question, and I had asked something similar earlier too.
Also, correct me if I am wrong, but I understand that each Prisma service is a connector that knows how to talk to a certain DB and
prisma generategives us a model that abstracts DB queries in multiple such connectors for our application level resolvers.
Going by this, I believe that a model should be tailored from connectors (to abstract them is its job), like Prisma does (Prisma does that, right?). And that since model abstracts away any array of backend services, my application level schema/API should be independent of the model, because resolvers talk to model and the model could take care of any query to any connected backend resource. Application API is independent of models, right?
If so is the case, how do I add new types to application server schema, such as changing a
type in Prisma datamodel (e.g.
type AddressType) to an
enum field on in the app schema? Any change would cascade, that is, relations such as
AddressType <- Address <- User <- Post, so should I rewrite all of the schema here again, if not, what’s the right way to import from Prisma.graphql and make necessary overwrites? How should I use
graphqlgen with this constraint?
Currently, I have an understanding that I should define an independent app schema with tool like graphql-code-generator to generate resolver signatures, where in resolvers I would use Prisma client to use the Prisma generated model via context param. What is wrong about this, or what are its constraints, if any? What is the most speedy approach to my problems?
If this post appears to you more of a confusion, that a query, it’s because I am confused! Please pull out some time to guide me, I am stuck in this spiral…
EDIT: I am reading this github post by tim and it confirms my assumptions as I see it. I am keeping it open since I need to fundamentally get this right!
EDIT2: Had quit
graphqlgen after facing the (open) issue, where it got itself in an infinite loop. Reading its docs again, and realising again that I could define whatever schema at app server, plus a model file, and resolvers would be generated with Prisma context.