prisma-nestjs-graphql 14.2.2 → 14.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/index.js +20 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -126,6 +126,13 @@ Disable usage of graphql `ID` type and use `Int/Float` for fields marked as `@id
|
|
|
126
126
|
Type: `boolean`
|
|
127
127
|
Default: `false`
|
|
128
128
|
|
|
129
|
+
#### `requireSingleFieldsInWhereUniqueInput`
|
|
130
|
+
|
|
131
|
+
When a `Model`s `WhereUniqueInput` class has only a single field, mark that field as **required** (TypeScript) and **not nullable** (GraphQL).
|
|
132
|
+
See [#58](https://github.com/unlight/prisma-nestjs-graphql/issues/58) for more details.
|
|
133
|
+
Type: `boolean`
|
|
134
|
+
Default: `false`
|
|
135
|
+
|
|
129
136
|
#### `useInputType`
|
|
130
137
|
|
|
131
138
|
Since GraphQL does not support input union type, this setting map
|
package/index.js
CHANGED
|
@@ -1278,6 +1278,24 @@ function registerEnum(enumType, args) {
|
|
|
1278
1278
|
});
|
|
1279
1279
|
}
|
|
1280
1280
|
|
|
1281
|
+
// src/handlers/require-single-fields-in-whereunique-input.ts
|
|
1282
|
+
function requireSingleFieldsInWhereUniqueInput(eventEmitter) {
|
|
1283
|
+
eventEmitter.on("BeforeInputType", beforeInputType3);
|
|
1284
|
+
}
|
|
1285
|
+
function beforeInputType3(args) {
|
|
1286
|
+
const { inputType: inputType2 } = args;
|
|
1287
|
+
if (!isWhereUniqueInputType(inputType2.name) || inputType2.fields.length !== 1) {
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
for (const field of inputType2.fields) {
|
|
1291
|
+
field.isRequired = true;
|
|
1292
|
+
field.isNullable = false;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
function isWhereUniqueInputType(name) {
|
|
1296
|
+
return name.endsWith("WhereUniqueInput");
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1281
1299
|
// src/handlers/warning.ts
|
|
1282
1300
|
function warning(message) {
|
|
1283
1301
|
if (Array.isArray(message)) {
|
|
@@ -1354,6 +1372,7 @@ function createConfig(data) {
|
|
|
1354
1372
|
purgeOutput: toBoolean(config.purgeOutput),
|
|
1355
1373
|
useInputType: createUseInputType(config.useInputType),
|
|
1356
1374
|
noTypeId: toBoolean(config.noTypeId),
|
|
1375
|
+
requireSingleFieldsInWhereUniqueInput: toBoolean(config.requireSingleFieldsInWhereUniqueInput),
|
|
1357
1376
|
decorate
|
|
1358
1377
|
};
|
|
1359
1378
|
}
|
|
@@ -1583,6 +1602,7 @@ async function generate(args) {
|
|
|
1583
1602
|
config.reExport !== ReExport.None && reExport(eventEmitter);
|
|
1584
1603
|
config.emitSingle && emitSingle(eventEmitter);
|
|
1585
1604
|
config.purgeOutput && purgeOutput(eventEmitter);
|
|
1605
|
+
config.requireSingleFieldsInWhereUniqueInput && requireSingleFieldsInWhereUniqueInput(eventEmitter);
|
|
1586
1606
|
const models = new Map();
|
|
1587
1607
|
const modelNames = [];
|
|
1588
1608
|
const modelFields = new Map();
|
package/package.json
CHANGED