Generate object types, inputs, args, etc. from prisma schema file for usage with @nestjs/graphql module.
npm install --save-dev prisma-nestjs-graphql
- Add new generator section to
schema.prisma
file
generator nestgraphql {
provider = "node node_modules/prisma-nestjs-graphql"
output = "../src"
}
- Run prisma generate
npx prisma generate
output
Output folder relative to this schema fileoutputFilePattern
File pattern (default:{feature}/{dasherizedName}.{type}.ts
)
Possible tokens:{feature}
- model name in dashed case or 'prisma' if unknown{name}
- name of model/input/arg{dasherizedName}
- dashed-case name of model/input/arg without suffix{type}
- short type name (model, input)
- Todo - unlight#2
- https://ts-ast-viewer.com/
- https://github.com/unlight/nestjs-graphql-prisma-realworld-example-app
- https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-schema/data-model
- JSON type for the code first approach - nestjs/graphql#111 (comment)
- https://github.com/paljs/prisma-tools/tree/master/packages/plugins