Skip to content

Commit

Permalink
chore(docs): add documentation regarding prismaClientImportId (#53)
Browse files Browse the repository at this point in the history
Co-authored-by: Jason Kuhrt <jasonkuhrt@me.com>
  • Loading branch information
iddan and jasonkuhrt committed May 25, 2021
1 parent ae7563e commit 7dfcd0c
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -598,10 +598,36 @@ query {
})

$settings({
prismaClientContextField = 'db', // <-- Tell Nexus Prisma
prismaClientContextField: 'db', // <-- Tell Nexus Prisma
})
```

##### `prismaClientImportId: string`

- **@summary** Where Nexus Prisma will try to import your generated Prisma Client from. You should not need to configure this normally because Nexus Prisma generator automatically reads the Prisma Client generator `output` setting if you have set it. The value here will be used in a dynamic import thus following Node's path resolution rules. You can pass a node_modules package like `foo` `@prisma/client`, `@my/custom/thing` etc. or you can pass an absolute module/file path `/my/custom/thing` / `/my/custom/thing/index.js` or finally a relative path to be resolved relative to the location of Nexus Prisma source files (you probably don't want this).

- **@remarks** Nexus Prisma imports Prisma client internally for two reasons: 1) validation wherein a class reference to Prisma Client is needed for some `instanceof` checks and 2) for acquiring the DMMF as Nexus Prisma relies on some post-processing done by Prisma Client generator.

- **@example**

```ts
// src/main.ts

import { PrismaClient } from '@prisma/client'
import { ApolloServer } from 'apollo-server'
import { makeSchema } from 'nexus'
import { User, Post, $settings } from 'nexus-prisma'

new ApolloServer({
schema: makeSchema({
types: [],
}),
})

$settings({
prismaClientImportId: '@my/custom/thing',
})

### Generator Settings

You are able to control certain aspects of the Nexus Prisma code generation.
Expand Down

0 comments on commit 7dfcd0c

Please sign in to comment.