prisma-nestjs-graphql
Advanced tools
Comparing version
20
index.js
@@ -1281,2 +1281,20 @@ var __create = Object.create; | ||
// src/handlers/require-single-fields-in-whereunique-input.ts | ||
function requireSingleFieldsInWhereUniqueInput(eventEmitter) { | ||
eventEmitter.on("BeforeInputType", beforeInputType3); | ||
} | ||
function beforeInputType3(args) { | ||
const { inputType: inputType2 } = args; | ||
if (!isWhereUniqueInputType(inputType2.name) || inputType2.fields.length !== 1) { | ||
return; | ||
} | ||
for (const field of inputType2.fields) { | ||
field.isRequired = true; | ||
field.isNullable = false; | ||
} | ||
} | ||
function isWhereUniqueInputType(name) { | ||
return name.endsWith("WhereUniqueInput"); | ||
} | ||
// src/handlers/warning.ts | ||
@@ -1358,2 +1376,3 @@ function warning(message) { | ||
noTypeId: toBoolean(config.noTypeId), | ||
requireSingleFieldsInWhereUniqueInput: toBoolean(config.requireSingleFieldsInWhereUniqueInput), | ||
decorate | ||
@@ -1588,2 +1607,3 @@ }; | ||
config.purgeOutput && purgeOutput(eventEmitter); | ||
config.requireSingleFieldsInWhereUniqueInput && requireSingleFieldsInWhereUniqueInput(eventEmitter); | ||
const models = new Map(); | ||
@@ -1590,0 +1610,0 @@ const modelNames = []; |
{ | ||
"name": "prisma-nestjs-graphql", | ||
"version": "14.2.2", | ||
"version": "14.3.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Generate object types, inputs, args, etc. from prisma schema file for usage with @nestjs/graphql module", |
@@ -129,2 +129,9 @@ # prisma-nestjs-graphql | ||
#### `requireSingleFieldsInWhereUniqueInput` | ||
When a `Model`s `WhereUniqueInput` class has only a single field, mark that field as **required** (TypeScript) and **not nullable** (GraphQL). | ||
See [#58](https://github.com/unlight/prisma-nestjs-graphql/issues/58) for more details. | ||
Type: `boolean` | ||
Default: `false` | ||
#### `useInputType` | ||
@@ -131,0 +138,0 @@ |
78455
1.39%1661
1.16%582
1.22%