NestJS-Prisma-GraphQL-Generator tool for generating GraphQL resolvers for your NestJS application based on the prisma schema of your project.
Before you begin, ensure you have met the following requirements:
- Your project uses the latest version of Prisma and NestJS
To install NestJS-Prisma-GraphQL-Generator, follow these steps:
npm i nestjs-prisma-graphql-generator --save-dev
or
yarn add nestjs-prisma-graphql-generator --dev
To use NestJS-Prisma-GraphQL-Generator, follow these steps:
- configure the prisma generator
- add NestJS-Prisma-GraphQL-Generator as a subsequent generator to your prisma.schema
- optionally configure NestJS-Prisma-GraphQL-Generator as described in the Configuration section
- run prisma generate
- import generated types, enums and resolvers from
path/to/prisma/schema/@generated/nestjs
Create a new generator in your prisma schema and provide the import path of your prisma service:
generator nestjs {
provider = "nestjs-prisma-graphql"
prismaServiceImportPath = "@your/prisma-service"
}
The following additional settings can be configured within the generator block of your prisma schema:
- the input arguments name; default setting:
inputArgumentsName = input
- the named prisma service import; default setting:
prismaServiceImport = PrismaService
To enable the Prisma Select integration, set includePrismaSelect
to true
:
generator nestjs {
provider = "nestjs-prisma-graphql"
includePrismaSelect = true
}
- Enums
- Models
- Input Types
- Output Types
- Resolvers
All supported objects can be used as the regular NestJS GraphQL object equivalents.
Resolvers can be imported on an individual base and used within the providers
array of your modules
- support for adding custom decorators to the generated objects
To contribute to NestJS-Prisma-GraphQL-Generator, follow these steps:
- Fork this repository.
- Create a branch:
git checkout -b <branch_name>
. - Make your changes and commit them:
git commit -m '<commit_message>'
- Push to the original branch:
git push origin nestjs-prisma-graphql-generator/main
- Create the pull request.
Alternatively see the GitHub documentation on creating a pull request.
Thanks to the following people who have contributed to this project:
This project uses the MIT license.