Skip to main content

Installation

info

Prisma 7 requires Node.js 20.19+, 22.12+, or 24+ and TypeScript 5.4+.

TypeGraphQL

First of all, you should perform all the steps described in the TypeGraphQL installation instruction:

https://typegraphql.com/docs/installation.html

@cerebruminc/typegraphql-prisma generator

After that, you have to install the generator, as a dev dependency:

npm i -D @cerebruminc/typegraphql-prisma

Furthermore, @cerebruminc/typegraphql-prisma requires Prisma to work properly, so please install Prisma dependencies if you don't have them already installed:

npm i -D prisma@^7.8.0
npm i @prisma/client@^7.8.0
caution

Be aware that @cerebruminc/typegraphql-prisma is designed to work with selected versions of Prisma. This generator is designed to work and tested with the features of the 7.0.0 release.

You can update both prisma and @prisma/client to a newer version, matching ^7.0.0 in order to receive important bugfixes. However, make sure you don't use the new features from a newer Prisma version, especially the ones behind a preview flag.

If you encounter a new Prisma feature not supported yet, please check on GitHub issues and create a new issue, if that wasn't already reported, and downgrade the Prisma version, if needed.

Prisma 7 requires a database driver adapter when constructing PrismaClient. Install the adapter and driver for your database. For PostgreSQL, for example:

npm i @prisma/adapter-pg pg

Additional dependencies

You also need to install the GraphQL Scalars library to support Prisma's Json and BigInt types. The Prisma 7 Bytes scalar is generated by typegraphql-prisma itself and uses base64 strings in GraphQL:

npm i graphql-scalars

In order to properly support the aggregate and group by queries, the graphql-fields package is used, so it also has to be installed:

npm i graphql-fields @types/graphql-fields

Finally, please also install the tslib package, which is required for applying the additional decorators properly:

npm i tslib

TypeScript configuration

As prisma emits multiple files, make sure you have your tsconfig set properly to "module": "commonjs":

{
"compilerOptions": {
"target": "es2021",
"module": "commonjs",
"lib": ["es2021"],
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
}

Otherwise you may experience runtime errors like ReferenceError: Cannot access 'BankAccountWhereInput' before initialization. It's because those generated files rely on each other, so commonjs is needed to handle that cyclic imports.