prisma-labs / graphqlgen

⚙️ Generate type-safe resolvers based upon your GraphQL Schema
MIT License
818 stars 54 forks source link

Prisma scaffolding plugin #128

Open schickling opened 6 years ago

schickling commented 6 years ago

Once we're supporting GraphQL directives (see #83) and a plugin system (see #84), there could be a Prisma plugin that automatically scaffolds the relation resolvers (similar to the forwardTo functionality of graphql-binding). Here is an example (syntax still WIP):

schema.graphql

# import Post from '../generated/prisma.graphql'

type Query {
  feed: [Post!]! @prisma(query: "posts")
}

Further idea: This combined with the usage of graphql-import could lead to a very concise and minimal setup where for most cases it's enough to change something in your datamodel.prisma and the schema.graphql file + resolvers will be adjusted automatically.

vjsingh commented 6 years ago

From this discussion, Nikolas mentions that "It is true that the client requires you to implement type resolvers for types that have relations to other types"

Just trying to understand - does this idea solve that use case? I am having to define lots of type resolvers for relations that I did not have to write under prisma-bindings, it's quite a bit of boilerplate code

vjsingh commented 5 years ago

@schickling Any update on this? When adding new relation fields in my datamodel.prisma I have to add boilerplate resolvers, and these are adding up quickly