Confused about the application schema and generated code

prisma

#1

I’m trying to create a Graphql application API that connects to prisma. I’m a little confused about what the $prisma generate command does though.

From what i understand $prisma generate will create the prisma-client which is used by the graphql server as a binding. Does the generate command also produce a schema that my graphql server can use?

If it does, how can i filter the resolvers that are exposed to the end user?

If not, do i need to generate my application schema by hand and simply import the prisma generated types?


#2

Hi @danramosd,

I believe it is actually prisma deploy to generate your graphql schema.

prisma generate only generates the prisma client.

If not, do i need to generate my application schema by hand and simply import the prisma generated types?

It doesn’t so you have two options:

  • write another schema and then use some code generation like graphqlgen to generate your resolver types and resolver skeletons.
  • use the new recommended code(resolver) first approach. nexus-prisma

#3

prisma deploy does not generate a schema. But you can add prisma generate to the post-deploy hook, meaning prisma generate would be called once prisma deploy is done.

prisma generate will look in the prisma.yml file, and generate whatever is configured to be generated there. You could generate multiple instances of the schema or client, or maybe the client in multiple languages if you wish. Here is my prisma.yml file, configured to generate both a schema file and a prisma client:


#4

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.