prisma-nestjs-graphql 14.5.0 → 14.6.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 +28 -0
- package/index.js +46 -39
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -571,6 +571,34 @@ export class User {
|
|
|
571
571
|
}
|
|
572
572
|
```
|
|
573
573
|
|
|
574
|
+
### @Directive()
|
|
575
|
+
|
|
576
|
+
Allow attach `@Directive` decorator from `@nestjs/graphql`
|
|
577
|
+
|
|
578
|
+
GraphQL federation example:
|
|
579
|
+
|
|
580
|
+
```
|
|
581
|
+
/// @Directive({ arguments: ['@extends'] })
|
|
582
|
+
/// @Directive({ arguments: ['@key(fields: "id")'] })
|
|
583
|
+
model User {
|
|
584
|
+
/// @Directive({ arguments: ['@external'] })
|
|
585
|
+
id String @id
|
|
586
|
+
}
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
May generate:
|
|
590
|
+
|
|
591
|
+
```ts
|
|
592
|
+
@ObjectType()
|
|
593
|
+
@Directive('@extends')
|
|
594
|
+
@Directive('@key(fields: "id")')
|
|
595
|
+
export class User {
|
|
596
|
+
@Field(() => ID, { nullable: false })
|
|
597
|
+
@Directive('@external')
|
|
598
|
+
id!: string;
|
|
599
|
+
}
|
|
600
|
+
```
|
|
601
|
+
|
|
574
602
|
#### @ObjectType()
|
|
575
603
|
|
|
576
604
|
Allow rename type in schema and mark as abstract.
|
package/index.js
CHANGED
|
@@ -520,7 +520,7 @@ function propertyStructure(args) {
|
|
|
520
520
|
|
|
521
521
|
// src/handlers/input-type.ts
|
|
522
522
|
function inputType(args) {
|
|
523
|
-
var _a, _b;
|
|
523
|
+
var _a, _b, _c, _d;
|
|
524
524
|
const {
|
|
525
525
|
inputType: inputType2,
|
|
526
526
|
fileType,
|
|
@@ -635,22 +635,21 @@ function inputType(args) {
|
|
|
635
635
|
});
|
|
636
636
|
if (isCustomsApplicable) {
|
|
637
637
|
for (const options of settings || []) {
|
|
638
|
-
if (
|
|
639
|
-
|
|
638
|
+
if ((_c = options.kind === "Decorator" && options.input && ((_b = options.match) == null ? void 0 : _b.call(options, name))) != null ? _c : true) {
|
|
639
|
+
property.decorators.push({
|
|
640
|
+
name: options.name,
|
|
641
|
+
arguments: options.arguments
|
|
642
|
+
});
|
|
643
|
+
(0, import_assert2.ok)(options.from, "Missed 'from' part in configuration or field setting");
|
|
644
|
+
importDeclarations.create(options);
|
|
640
645
|
}
|
|
641
|
-
property.decorators.push({
|
|
642
|
-
name: options.name,
|
|
643
|
-
arguments: options.arguments
|
|
644
|
-
});
|
|
645
|
-
(0, import_assert2.ok)(options.from, "Missed 'from' part in configuration or field setting");
|
|
646
|
-
importDeclarations.create(options);
|
|
647
646
|
}
|
|
648
647
|
}
|
|
649
648
|
for (const decorate of config.decorate) {
|
|
650
649
|
if (decorate.isMatchField(name) && decorate.isMatchType(inputType2.name)) {
|
|
651
650
|
property.decorators.push({
|
|
652
651
|
name: decorate.name,
|
|
653
|
-
arguments: (
|
|
652
|
+
arguments: (_d = decorate.arguments) == null ? void 0 : _d.map((x) => (0, import_pupa.default)(x, { propertyType }))
|
|
654
653
|
});
|
|
655
654
|
importDeclarations.create(decorate);
|
|
656
655
|
}
|
|
@@ -726,7 +725,7 @@ var ObjectSettings = class extends Array {
|
|
|
726
725
|
}
|
|
727
726
|
};
|
|
728
727
|
function createObjectSettings(args) {
|
|
729
|
-
var _a, _b, _c, _d;
|
|
728
|
+
var _a, _b, _c, _d, _e;
|
|
730
729
|
const { config, text } = args;
|
|
731
730
|
const result = new ObjectSettings();
|
|
732
731
|
const textLines = text.split("\n");
|
|
@@ -765,14 +764,22 @@ function createObjectSettings(args) {
|
|
|
765
764
|
name: options.name,
|
|
766
765
|
isAbstract: options.isAbstract
|
|
767
766
|
};
|
|
767
|
+
} else if (name === "Directive" && ((_d = match.groups) == null ? void 0 : _d.args)) {
|
|
768
|
+
const options = customType(match.groups.args);
|
|
769
|
+
(0, import_lodash4.merge)(element, { model: true, from: "@nestjs/graphql" }, options, {
|
|
770
|
+
name,
|
|
771
|
+
namespace: false,
|
|
772
|
+
kind: "Decorator",
|
|
773
|
+
arguments: Array.isArray(options.arguments) ? options.arguments.map((s) => import_json52.default.stringify(s)) : options.arguments
|
|
774
|
+
});
|
|
768
775
|
} else {
|
|
769
776
|
const namespace = getNamespace(name);
|
|
770
777
|
element.namespaceImport = namespace;
|
|
771
778
|
const options = {
|
|
772
779
|
name,
|
|
773
|
-
arguments: (((
|
|
780
|
+
arguments: (((_e = match.groups) == null ? void 0 : _e.args) || "").split(",").map((s) => (0, import_lodash4.trim)(s)).filter(Boolean)
|
|
774
781
|
};
|
|
775
|
-
(0, import_lodash4.merge)(element, config.fields[namespace], options);
|
|
782
|
+
(0, import_lodash4.merge)(element, namespace && config.fields[namespace], options);
|
|
776
783
|
}
|
|
777
784
|
result.push(element);
|
|
778
785
|
}
|
|
@@ -842,6 +849,9 @@ function parseArgs(string) {
|
|
|
842
849
|
}
|
|
843
850
|
}
|
|
844
851
|
function getNamespace(name) {
|
|
852
|
+
if (name === void 0) {
|
|
853
|
+
return void 0;
|
|
854
|
+
}
|
|
845
855
|
let result = String(name);
|
|
846
856
|
if (result.includes(".")) {
|
|
847
857
|
[result] = result.split(".");
|
|
@@ -886,7 +896,7 @@ function getOutputTypeName(name) {
|
|
|
886
896
|
// src/handlers/model-output-type.ts
|
|
887
897
|
var nestjsGraphql = "@nestjs/graphql";
|
|
888
898
|
function modelOutputType(outputType2, args) {
|
|
889
|
-
var _a, _b, _c, _d;
|
|
899
|
+
var _a, _b, _c, _d, _e, _f;
|
|
890
900
|
const { getSourceFile, models, config, modelFields, fieldSettings, eventEmitter } = args;
|
|
891
901
|
const model = models.get(outputType2.name);
|
|
892
902
|
(0, import_assert3.ok)(model, `Cannot find model by name ${outputType2.name}`);
|
|
@@ -1010,21 +1020,20 @@ function modelOutputType(outputType2, args) {
|
|
|
1010
1020
|
]
|
|
1011
1021
|
});
|
|
1012
1022
|
for (const setting of settings || []) {
|
|
1013
|
-
if (
|
|
1014
|
-
|
|
1023
|
+
if (shouldBeDecorated(setting) && ((_e = (_d = setting.match) == null ? void 0 : _d.call(setting, field.name)) != null ? _e : true)) {
|
|
1024
|
+
property.decorators.push({
|
|
1025
|
+
name: setting.name,
|
|
1026
|
+
arguments: setting.arguments
|
|
1027
|
+
});
|
|
1028
|
+
(0, import_assert3.ok)(setting.from, "Missed 'from' part in configuration or field setting");
|
|
1029
|
+
importDeclarations.create(setting);
|
|
1015
1030
|
}
|
|
1016
|
-
property.decorators.push({
|
|
1017
|
-
name: setting.name,
|
|
1018
|
-
arguments: setting.arguments
|
|
1019
|
-
});
|
|
1020
|
-
(0, import_assert3.ok)(setting.from, "Missed 'from' part in configuration or field setting");
|
|
1021
|
-
importDeclarations.create(setting);
|
|
1022
1031
|
}
|
|
1023
1032
|
for (const decorate of config.decorate) {
|
|
1024
1033
|
if (decorate.isMatchField(field.name) && decorate.isMatchType(outputTypeName)) {
|
|
1025
1034
|
property.decorators.push({
|
|
1026
1035
|
name: decorate.name,
|
|
1027
|
-
arguments: (
|
|
1036
|
+
arguments: (_f = decorate.arguments) == null ? void 0 : _f.map((x) => (0, import_pupa2.default)(x, { propertyType }))
|
|
1028
1037
|
});
|
|
1029
1038
|
importDeclarations.create(decorate);
|
|
1030
1039
|
}
|
|
@@ -1037,14 +1046,13 @@ function modelOutputType(outputType2, args) {
|
|
|
1037
1046
|
});
|
|
1038
1047
|
}
|
|
1039
1048
|
for (const setting of modelSettings || []) {
|
|
1040
|
-
if (
|
|
1041
|
-
|
|
1049
|
+
if (shouldBeDecorated(setting)) {
|
|
1050
|
+
classStructure.decorators.push({
|
|
1051
|
+
name: setting.name,
|
|
1052
|
+
arguments: setting.arguments
|
|
1053
|
+
});
|
|
1054
|
+
importDeclarations.create(setting);
|
|
1042
1055
|
}
|
|
1043
|
-
classStructure.decorators.push({
|
|
1044
|
-
name: setting.name,
|
|
1045
|
-
arguments: setting.arguments
|
|
1046
|
-
});
|
|
1047
|
-
importDeclarations.create(setting);
|
|
1048
1056
|
}
|
|
1049
1057
|
if (exportDeclaration) {
|
|
1050
1058
|
sourceFile.set({
|
|
@@ -1106,7 +1114,7 @@ var import_lodash6 = __toModule(require("lodash"));
|
|
|
1106
1114
|
var import_ts_morph6 = __toModule(require("ts-morph"));
|
|
1107
1115
|
var nestjsGraphql2 = "@nestjs/graphql";
|
|
1108
1116
|
function outputType(outputType2, args) {
|
|
1109
|
-
var _a, _b, _c;
|
|
1117
|
+
var _a, _b, _c, _d, _e;
|
|
1110
1118
|
const { getSourceFile, models, eventEmitter, fieldSettings, getModelName: getModelName2 } = args;
|
|
1111
1119
|
const importDeclarations = new ImportDeclarationMap();
|
|
1112
1120
|
const fileType = "output";
|
|
@@ -1205,15 +1213,14 @@ function outputType(outputType2, args) {
|
|
|
1205
1213
|
});
|
|
1206
1214
|
if (isCustomsApplicable) {
|
|
1207
1215
|
for (const options of settings || []) {
|
|
1208
|
-
if (
|
|
1209
|
-
|
|
1216
|
+
if ((_e = options.kind === "Decorator" && options.output && ((_d = options.match) == null ? void 0 : _d.call(options, field.name))) != null ? _e : true) {
|
|
1217
|
+
property.decorators.push({
|
|
1218
|
+
name: options.name,
|
|
1219
|
+
arguments: options.arguments
|
|
1220
|
+
});
|
|
1221
|
+
(0, import_assert4.ok)(options.from, "Missed 'from' part in configuration or field setting");
|
|
1222
|
+
importDeclarations.create(options);
|
|
1210
1223
|
}
|
|
1211
|
-
property.decorators.push({
|
|
1212
|
-
name: options.name,
|
|
1213
|
-
arguments: options.arguments
|
|
1214
|
-
});
|
|
1215
|
-
(0, import_assert4.ok)(options.from, "Missed 'from' part in configuration or field setting");
|
|
1216
|
-
importDeclarations.create(options);
|
|
1217
1224
|
}
|
|
1218
1225
|
}
|
|
1219
1226
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prisma-nestjs-graphql",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.6.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Generate object types, inputs, args, etc. from prisma schema file for usage with @nestjs/graphql module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -67,10 +67,10 @@
|
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@commitlint/cli": "^13.2.1",
|
|
69
69
|
"@commitlint/config-conventional": "^13.2.0",
|
|
70
|
-
"@nestjs/common": "^8.
|
|
71
|
-
"@nestjs/core": "^8.
|
|
70
|
+
"@nestjs/common": "^8.1.1",
|
|
71
|
+
"@nestjs/core": "^8.1.1",
|
|
72
72
|
"@nestjs/graphql": "^9.0.6",
|
|
73
|
-
"@nestjs/platform-express": "^8.
|
|
73
|
+
"@nestjs/platform-express": "^8.1.1",
|
|
74
74
|
"@paljs/plugins": "^4.0.8",
|
|
75
75
|
"@prisma/client": "^3.2.1",
|
|
76
76
|
"@semantic-release/changelog": "^6.0.0",
|
|
@@ -78,12 +78,12 @@
|
|
|
78
78
|
"@types/flat": "^5.0.2",
|
|
79
79
|
"@types/lodash": "^4.14.175",
|
|
80
80
|
"@types/mocha": "^9.0.0",
|
|
81
|
-
"@types/node": "^16.
|
|
81
|
+
"@types/node": "^16.11.0",
|
|
82
82
|
"@types/pluralize": "^0.0.29",
|
|
83
83
|
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
84
84
|
"@typescript-eslint/parser": "^4.33.0",
|
|
85
|
-
"apollo-server-express": "^3.
|
|
86
|
-
"c8": "^7.
|
|
85
|
+
"apollo-server-express": "^3.4.0",
|
|
86
|
+
"c8": "^7.10.0",
|
|
87
87
|
"class-transformer": "^0.4.0",
|
|
88
88
|
"class-validator": "^0.13.1",
|
|
89
89
|
"commitizen": "^4.2.4",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"eslint": "^7.32.0",
|
|
93
93
|
"eslint-import-resolver-node": "^0.3.6",
|
|
94
94
|
"eslint-plugin-etc": "^1.5.4",
|
|
95
|
-
"eslint-plugin-import": "^2.25.
|
|
95
|
+
"eslint-plugin-import": "^2.25.2",
|
|
96
96
|
"eslint-plugin-only-warn": "^1.0.3",
|
|
97
97
|
"eslint-plugin-prettier": "^4.0.0",
|
|
98
98
|
"eslint-plugin-promise": "^5.1.0",
|
|
@@ -107,9 +107,9 @@
|
|
|
107
107
|
"ghooks": "^2.0.4",
|
|
108
108
|
"git-branch-is": "^4.0.0",
|
|
109
109
|
"graphql": "^15.6.1",
|
|
110
|
-
"graphql-scalars": "^1.
|
|
110
|
+
"graphql-scalars": "^1.12.0",
|
|
111
111
|
"graphql-type-json": "^0.3.2",
|
|
112
|
-
"mocha": "^9.1.
|
|
112
|
+
"mocha": "^9.1.3",
|
|
113
113
|
"ololog": "^1.1.175",
|
|
114
114
|
"precise-commits": "^1.0.2",
|
|
115
115
|
"prettier": "^2.4.1",
|