npm package: @itez-io/nexus-plugin-prisma
Description: | Dependency | Version | |---|---| | `@prisma/client` | `^7.5.0` | | `nexus` | `1.3.0` | | `graphql` | `^16.6.0` |
Author: Flavian Desverne
Latest version: 7.5.0

<p align="center">
  <img src="https://i.imgur.com/8qvElTM.png" width="300" align="center" />
  <h1 align="center">@itez-io/nexus-plugin-prisma</h1>
</p>

This plugin integrates [Prisma](https://www.prisma.io/) into [Nexus](https://nexusjs.org/). It gives you an API to project fields from models defined in your Prisma schema into your GraphQL API. It also gives you an API to build GraphQL root fields that allow your API clients to query and mutate data.

You can find the [documentation on the Nexus website](https://nexusjs.org/docs/plugins/prisma/overview).

## Supported versions

| Dependency | Version |
|---|---|
| `@prisma/client` | `^7.5.0` |
| `nexus` | `1.3.0` |
| `graphql` | `^16.6.0` |

## Breaking changes from previous versions

### Naming strategy: `pluralize` → `xxxList`

The default naming for `findMany` CRUD operations has changed.

| Before (pluralize) | After (List suffix) |
|---|---|
| `t.crud.users()` | `t.crud.userList()` |
| `t.crud.blogPosts()` | `t.crud.blogPostList()` |

The `pluralize` dependency has been removed. Model names now use a `List` suffix instead. This eliminates unpredictable naming caused by irregular plurals (e.g. person→people).

### Prisma 7 migration

#### Runtime path change

Prisma 7 changed the internal runtime path.

```
// Prisma 5.x
@prisma/client/runtime/library

// Prisma 7.x
@prisma/client/runtime/client
```

The plugin handles this internally with automatic fallback, so no action is required on the user side.

#### DMMF internalization

All external DMMF dependencies have been removed:

- **`@prisma/client/runtime` type imports removed** — DMMF types are now defined internally via `src/dmmf/PrismaDMMF.ts` namespace.
- **`@prisma/client/generator-build` dependency removed** — `externalToInternalDmmf()` and `getMappings()` are now implemented within the plugin.

This makes the plugin resilient to Prisma internal API changes across version upgrades.

### New options: `schemaPath` and `dmmfDocument`

To reduce coupling with `@prisma/client` internals, two new options have been added for explicit DMMF source specification:

```typescript
// Option 1: Specify schema.prisma path directly (recommended)
nexusPrisma({
  schemaPath: resolve("prisma/schema.prisma"),
  experimentalCRUD: true,
})

// Option 2: Inject DMMF data directly
import dmmf from "./generated/dmmf.json"
nexusPrisma({
  dmmfDocument: dmmf,
  experimentalCRUD: true,
})

// Option 3: Legacy (no options) — auto-detection fallback
nexusPrisma({
  experimentalCRUD: true,
})
```

| Option | Behavior |
|---|---|
| `schemaPath` | Reads schema.prisma directly, skips auto-detection of `.prisma/client/` path |
| `dmmfDocument` | Skips DMMF acquisition entirely, uses provided data as-is |
| Neither | Falls back to legacy auto-detection logic (compatible with previous versions) |

Using `schemaPath` is recommended as it avoids fragile path detection and works reliably across Prisma versions.

## Installation

```
npm install @itez-io/nexus-plugin-prisma
# OR
yarn add @itez-io/nexus-plugin-prisma
```

## Usage notes

### AWS Lambda packaging

Make sure to include `@prisma/internals` in your AWS Lambda packaged `node_modules` folder, in addition to the `@prisma/client` package.

To mitigate overall package size issues, remove all `libquery_engine-debian-openssl-1.1.x.so.node` files under `node_modules/@prisma` as they are not leveraged by AWS Lambda.

## Package management

### Build, test

> build

```
yarn
yarn build
```

> test

`yarn test`

If tests need snapshot updates, run `yarn test:run:rebaseSnapshots`

### Dependencies versioning

> update all packages

```
yarn update:all
```