简体   繁体   中英

Prisma v2: generate a .graphql file to edit with?

I'm building a graphql server (with apollo-server ) on an existing postgresql db ( I cannot modify the db tables ).

Prisma can introspect the db and generate a schema.prisma file containing all db tables. To implement the graphql server, I need to define graphql types and queries and mutations manually.

With Prisma v1, this prisma.yml can generate a graphql file.

generate:
  - generator: graphql-schema
  output: ./generated/prisma.graphql

For Prisma v2, is there any way to generate a graphql file from schema.prisma ?

Then I can modify the graphql file by removing some types that do not needed to be exposed to front, and create queries and mutations by myself.

Prisma2 是一个 orm,与prisma1 不同,因此您可以使用nexus-plugin-prisma库从 Prisma 模式自动生成您的 GraphQL 类型和解析器

Prisma 2 is just an ORM unlike Prisma 1 that had a GraphQL layer. So you would need external libraries like this to autogenerate a GraphQL file. You can check out TypeGraphQL that does this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM