Reputation: 1102
I'm running prisma side by side with my graphql application API. I can run prisma generate
which produces the client side code and everything is great. However a majority of my endpoints on my application API are nothing more than a proxy to the prisma service. For example, I have a basic Font
data model that the user should be able to perform CRUD operations on.
As of now I'm manually creating those CRUD queries with hard coded argument. Is there a way I can simply import code from the prisma client to automagically create those CRUD operations?
Upvotes: 1
Views: 162
Reputation: 5747
I'm not sure if I fully understand but if you are trying to create CRUD methods on all your datatypes a service like GraphCool might work better than Prisma?
It's older and less customisable than Prisma but does come with Queries and Mutations setup for all your data types.
Upvotes: 0
Reputation: 20970
You cannot do that with prisma-client. It is expected that you will have your own services on top of Prisma layer that includes your simplified REST endpoints or application level GraphQL server, Authorization, etc.
However, if most of the time you are going to do this, then consider using prisma-bindings instead of prisma-client. It has a forwardTo
API but it is only gql to gql forwarding.
Note: For express.js, there is a mapping middleware, rest-graphql but has very limited use.
Upvotes: 1