Registry / devops / prisma-nestjs-graphql

prisma-nestjs-graphql

JSON →
library23.2.1jsnpmunverified

Generate NestJS GraphQL object types, inputs, args, and enums from a Prisma schema file. Current stable version is 23.2.1. It integrates with @nestjs/graphql and is released regularly. Key differentiators: generates only necessary imports, combines nested/nullable filters, and avoids generating resolvers (application-specific). It supports a structured JavaScript config file instead of flat schema keys, and provides options for decorators, custom imports, and scalar types. Requires @prisma/generator-helper and identity-type as peer dependencies.

npm install prisma-nestjs-graphql
INSTALL
IMPORT
SIG · PRISMA-NESTJS-GRAP
P
prisma-nestjs-graphql
devopsjavascriptv23.2.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ExternalConfig
✓ import { ExternalConfig } from 'prisma-nestjs-graphql'
✗ import ExternalConfig from 'prisma-nestjs-graphql'
Named export for TypeScript config file type. Default export is the config factory function.
default (config export)
✓ export default { output: '../src/@generated' }
✗ module.exports = { output: '../src/@generated' }
Config file must use ESM default export (type: 'module' in package.json or .mjs extension).
Generated types (e.g., User, UserCreateInput)
✓ import { User } from './@generated/user/user.model'
✗ import { User } from '@prisma/client'
Generated types are output to the configured output directory, not from @prisma/client. The exact path depends on outputFilePattern.

Shows basic usage: add generator to schema.prisma, run prisma generate, and import generated types.

// schema.prisma generator nestgraphql { provider = "prisma-nestjs-graphql" output = "../src/@generated" } model User { id Int @id @default(autoincrement()) email String @unique name String? posts Post[] } model Post { id Int @id @default(autoincrement()) title String content String? author User? @relation(fields: [authorId], references: [id]) authorId Int? } // Run: npx prisma generate // Then use in NestJS: import { ObjectType } from '@nestjs/graphql'; import { User } from './@generated/user/user.model'; @ObjectType() export class UserWithPosts extends User { @Field(() => [Post]) posts: Post[]; }
Debug
Known issues
breakingConfig file format changed from underscore-delimited keys to structured JS objects. Old flat keys are deprecated and may be removed in future versions.
fix
Migrate to configFile approach: create prisma/nestgraphql.config.mjs and move all options there as structured objects.
affects: <23.0.0
deprecatedUsing underscore-delimited keys (fields_Validator_from, decorate_1_type, etc.) directly in schema.prisma is deprecated.
fix
Use a structured config file as shown in the README.
affects: >=23.0.0
gotchaThe output path in configFile is relative to the config file, not the schema file. If defined in schema.prisma, it's relative to the schema file.
fix
Use absolute paths or ensure relative path is correct for your project structure.
affects: >=23.0.0
gotchaConfig file must use ESM default export (export default) and be named .mjs or have 'type': 'module' in package.json.
fix
Use .mjs extension or set 'type': 'module' in package.json.
affects: >=23.0.0
gotchaAdditional graphql scalar types (graphql-type-json, prisma-graphql-type-decimal) must be installed manually if models use Decimal or Json types.
fix
Run: npm install graphql-type-json prisma-graphql-type-decimal
affects: all
Errors
Common errors & fixes
Error: Generator 'nestgraphql' failed: Could not find generator options...
Missing or misconfigured configFile or output path.
fix
Ensure output path is correctly specified and configFile points to a valid .mjs file.
Cannot find module 'identity-type'
Missing peer dependency identity-type.
fix
Run: npm install identity-type --save-dev
Unknown type 'Decimal'. Please install prisma-graphql-type-decimal
Prisma model uses Decimal type but the scalar type is not registered.
fix
Install prisma-graphql-type-decimal and register in GraphQL module.
Upgrade
Version history
23.2.1latest on npm
Audit
Dependencies
@prisma/generator-helperrequiredRequired to run as a Prisma generator (peer dependency).
identity-typerequiredProvides identity type utilities for generated types (peer dependency).
Agent activity
7 hits · last 30 days
node
6
Resources
prisma-nestjs-graphql — npm install prisma-nestjs-graphql · libregistry