Use demo resolvers in local deployment?

prisma

#1

When deploying to the Demo server I get tons of nice API endpoints and options out if the box like sorting, skipping records, etc. just from providing a GraphQL schema. When I switch to a local deployment, it’s like I start from scratch and I have to implement these resolvers manually which takes a while.

Is there a way to get the best of both worlds and deploy locally, but with all of those sorting, skipping, etc. resolvers auto-generated for me? I would like to add authentication and permissions on top, but it would save a lot of time if the resolvers were auto-generated and then I could edit them rather than having to create them all by hand.


#2

Check this out https://github.com/maticzav/graphql-middleware-forward-binding, might be of some help.

You can just import the generated schema or even better, copy everything and remove all references to Node interface.

Permissions? Check out GraphQL Shield, https://github.com/maticzav/graphql-shield

Hope this helps you! :slightly_smiling_face:


#3

Why do you suggest to remove the Node interface?


#4

If you decide to import the generated schema from Prisma, it still includes Node interface. When graphql-tools try to generate the GraphQLSchema instance the type resolver is missing because it cannot be auto-generated which causes the error.


#5

Ah I see - that’s not an error but a warning, and you can either implement a Node type resolver or disable the warning using a server setting. See more information here: https://github.com/prismagraphql/prisma/issues/2225 :slight_smile:


#6

Thanks. Is there a CLI command to generate the resolvers? Or do I have to deploy to Prisma servers and then somehow copy the code from there?


#7

@everdev you only need schema. Resolvers are automatically generated by graphql-tools and graphql-middleware-forward-binding.

Check out the example in README. :slightly_smiling_face:


#8

Thanks! https://github.com/maticzav/graphql-middleware-forward-binding works like a charm :slight_smile: