prisma-nestjs-graphql 14.4.0 → 14.6.1
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 +72 -3
- package/index.js +127 -92
- package/package.json +42 -40
package/README.md
CHANGED
|
@@ -128,10 +128,11 @@ Default: `false`
|
|
|
128
128
|
|
|
129
129
|
#### `requireSingleFieldsInWhereUniqueInput`
|
|
130
130
|
|
|
131
|
-
When a
|
|
131
|
+
When a model `*WhereUniqueInput` class has only a single field, mark that field as **required** (TypeScript) and **not nullable** (GraphQL).
|
|
132
132
|
See [#58](https://github.com/unlight/prisma-nestjs-graphql/issues/58) for more details.
|
|
133
133
|
Type: `boolean`
|
|
134
|
-
Default: `false`
|
|
134
|
+
Default: `false`
|
|
135
|
+
**Note**: It will break compatiblity between Prisma types and generated classes.
|
|
135
136
|
|
|
136
137
|
#### `useInputType`
|
|
137
138
|
|
|
@@ -345,6 +346,7 @@ generator nestgraphql {
|
|
|
345
346
|
fields_{namespace}_from = "module specifier"
|
|
346
347
|
fields_{namespace}_input = true | false
|
|
347
348
|
fields_{namespace}_output = true | false
|
|
349
|
+
fields_{namespace}_model = true | false
|
|
348
350
|
fields_{namespace}_defaultImport = "default import name" | true
|
|
349
351
|
fields_{namespace}_namespaceImport = "namespace import name"
|
|
350
352
|
fields_{namespace}_namedImport = true | false
|
|
@@ -367,7 +369,14 @@ Default: `false`
|
|
|
367
369
|
|
|
368
370
|
##### `fields_{namespace}_output`
|
|
369
371
|
|
|
370
|
-
Means that it will be applied on output types (classes decorated by `ObjectType`)
|
|
372
|
+
Means that it will be applied on output types (classes decorated by `ObjectType`),
|
|
373
|
+
including models
|
|
374
|
+
Type: `boolean`
|
|
375
|
+
Default: `false`
|
|
376
|
+
|
|
377
|
+
##### `fields_{namespace}_model`
|
|
378
|
+
|
|
379
|
+
Means that it will be applied only on model types (classes decorated by `ObjectType`)
|
|
371
380
|
Type: `boolean`
|
|
372
381
|
Default: `false`
|
|
373
382
|
|
|
@@ -420,6 +429,36 @@ export class UserCreateInput {
|
|
|
420
429
|
}
|
|
421
430
|
```
|
|
422
431
|
|
|
432
|
+
Custom decorators can be applied on classes (models):
|
|
433
|
+
|
|
434
|
+
```
|
|
435
|
+
/// @NG.Directive('@extends')
|
|
436
|
+
/// @NG.Directive('@key(fields: "id")')
|
|
437
|
+
model User {
|
|
438
|
+
/// @NG.Directive('@external')
|
|
439
|
+
id String @id
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
generator nestgraphql {
|
|
443
|
+
fields_NG_from = "@nestjs/graphql"
|
|
444
|
+
fields_NG_output = false
|
|
445
|
+
fields_NG_model = true
|
|
446
|
+
}
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
May generate:
|
|
450
|
+
|
|
451
|
+
```ts
|
|
452
|
+
import * as NG from '@nestjs/graphql';
|
|
453
|
+
|
|
454
|
+
@NG.Directive('@extends')
|
|
455
|
+
@NG.Directive('@key(fields: "id")')
|
|
456
|
+
export class User {
|
|
457
|
+
@Field(() => ID, { nullable: false })
|
|
458
|
+
@NG.Directive('@external')
|
|
459
|
+
id!: string;
|
|
460
|
+
```
|
|
461
|
+
|
|
423
462
|
#### @FieldType()
|
|
424
463
|
|
|
425
464
|
Allow set custom GraphQL scalar type for field
|
|
@@ -533,6 +572,34 @@ export class User {
|
|
|
533
572
|
}
|
|
534
573
|
```
|
|
535
574
|
|
|
575
|
+
### @Directive()
|
|
576
|
+
|
|
577
|
+
Allow attach `@Directive` decorator from `@nestjs/graphql`
|
|
578
|
+
|
|
579
|
+
GraphQL federation example:
|
|
580
|
+
|
|
581
|
+
```
|
|
582
|
+
/// @Directive({ arguments: ['@extends'] })
|
|
583
|
+
/// @Directive({ arguments: ['@key(fields: "id")'] })
|
|
584
|
+
model User {
|
|
585
|
+
/// @Directive({ arguments: ['@external'] })
|
|
586
|
+
id String @id
|
|
587
|
+
}
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
May generate:
|
|
591
|
+
|
|
592
|
+
```ts
|
|
593
|
+
@ObjectType()
|
|
594
|
+
@Directive('@extends')
|
|
595
|
+
@Directive('@key(fields: "id")')
|
|
596
|
+
export class User {
|
|
597
|
+
@Field(() => ID, { nullable: false })
|
|
598
|
+
@Directive('@external')
|
|
599
|
+
id!: string;
|
|
600
|
+
}
|
|
601
|
+
```
|
|
602
|
+
|
|
536
603
|
#### @ObjectType()
|
|
537
604
|
|
|
538
605
|
Allow rename type in schema and mark as abstract.
|
|
@@ -569,6 +636,8 @@ export class User {}
|
|
|
569
636
|
|
|
570
637
|
## Similar Projects
|
|
571
638
|
|
|
639
|
+
- https://github.com/kimjbstar/prisma-class-generator
|
|
640
|
+
- https://github.com/odroe/nest-gql-mix
|
|
572
641
|
- https://github.com/rfermann/nestjs-prisma-graphql-generator
|
|
573
642
|
- https://github.com/madscience/graphql-codegen-nestjs
|
|
574
643
|
- https://github.com/wSedlacek/prisma-generators/tree/master/libs/nestjs
|
package/index.js
CHANGED
|
@@ -34,9 +34,6 @@ var __toModule = (module2) => {
|
|
|
34
34
|
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
// ../../../../.npm/_npx/7d72304e626f8399/node_modules/tsup/assets/cjs_shims.js
|
|
38
|
-
var importMetaUrlShim = typeof document === "undefined" ? new (require("url")).URL("file:" + __filename).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
39
|
-
|
|
40
37
|
// src/index.ts
|
|
41
38
|
var import_generator_helper = __toModule(require("@prisma/generator-helper"));
|
|
42
39
|
|
|
@@ -588,38 +585,46 @@ function inputType(args) {
|
|
|
588
585
|
propertyType,
|
|
589
586
|
isList
|
|
590
587
|
});
|
|
591
|
-
|
|
588
|
+
classStructure.properties.push(property);
|
|
592
589
|
if (propertySettings) {
|
|
593
590
|
importDeclarations.create(__spreadValues({}, propertySettings));
|
|
594
591
|
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
592
|
+
let graphqlType;
|
|
593
|
+
const shouldHideField = settings == null ? void 0 : settings.shouldHideField({
|
|
594
|
+
name: inputType2.name,
|
|
595
|
+
input: true
|
|
596
|
+
});
|
|
597
|
+
const fieldType = settings == null ? void 0 : settings.getFieldType({
|
|
598
|
+
name: inputType2.name,
|
|
599
|
+
input: true
|
|
600
|
+
});
|
|
601
|
+
if (fieldType && isCustomsApplicable && !shouldHideField) {
|
|
602
|
+
graphqlType = fieldType.name;
|
|
603
|
+
importDeclarations.create(__spreadValues({}, fieldType));
|
|
598
604
|
} else {
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
605
|
+
const graphqlImport = getGraphqlImport({
|
|
606
|
+
sourceFile,
|
|
607
|
+
location,
|
|
608
|
+
typeName,
|
|
609
|
+
getSourceFile
|
|
604
610
|
});
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
611
|
+
graphqlType = graphqlImport.name;
|
|
612
|
+
let referenceName = propertyType[0];
|
|
613
|
+
if (location === "enumTypes") {
|
|
614
|
+
referenceName = (0, import_lodash3.last)(referenceName.split(" "));
|
|
615
|
+
}
|
|
616
|
+
if (graphqlImport.specifier && !importDeclarations.has(graphqlImport.name) && (graphqlImport.name !== inputType2.name && !shouldHideField || shouldHideField && referenceName === graphqlImport.name)) {
|
|
617
|
+
importDeclarations.set(graphqlImport.name, {
|
|
618
|
+
namedImports: [{ name: graphqlImport.name }],
|
|
619
|
+
moduleSpecifier: graphqlImport.specifier
|
|
614
620
|
});
|
|
615
|
-
graphqlType = graphqlImport.name;
|
|
616
|
-
if (graphqlImport.name !== inputType2.name && graphqlImport.specifier && !importDeclarations.has(graphqlImport.name)) {
|
|
617
|
-
importDeclarations.set(graphqlImport.name, {
|
|
618
|
-
namedImports: [{ name: graphqlImport.name }],
|
|
619
|
-
moduleSpecifier: graphqlImport.specifier
|
|
620
|
-
});
|
|
621
|
-
}
|
|
622
621
|
}
|
|
622
|
+
}
|
|
623
|
+
(0, import_assert2.ok)(property.decorators, "property.decorators is undefined");
|
|
624
|
+
if (shouldHideField) {
|
|
625
|
+
importDeclarations.add("HideField", "@nestjs/graphql");
|
|
626
|
+
property.decorators.push({ name: "HideField", arguments: [] });
|
|
627
|
+
} else {
|
|
623
628
|
property.decorators.push({
|
|
624
629
|
name: "Field",
|
|
625
630
|
arguments: [
|
|
@@ -631,15 +636,14 @@ function inputType(args) {
|
|
|
631
636
|
});
|
|
632
637
|
if (isCustomsApplicable) {
|
|
633
638
|
for (const options of settings || []) {
|
|
634
|
-
if (
|
|
635
|
-
|
|
639
|
+
if ((_c = options.kind === "Decorator" && options.input && ((_b = options.match) == null ? void 0 : _b.call(options, name))) != null ? _c : true) {
|
|
640
|
+
property.decorators.push({
|
|
641
|
+
name: options.name,
|
|
642
|
+
arguments: options.arguments
|
|
643
|
+
});
|
|
644
|
+
(0, import_assert2.ok)(options.from, "Missed 'from' part in configuration or field setting");
|
|
645
|
+
importDeclarations.create(options);
|
|
636
646
|
}
|
|
637
|
-
property.decorators.push({
|
|
638
|
-
name: options.name,
|
|
639
|
-
arguments: options.arguments
|
|
640
|
-
});
|
|
641
|
-
(0, import_assert2.ok)(options.from, "Missed 'from' part in configuration or field setting");
|
|
642
|
-
importDeclarations.create(options);
|
|
643
647
|
}
|
|
644
648
|
}
|
|
645
649
|
for (const decorate of config.decorate) {
|
|
@@ -722,7 +726,7 @@ var ObjectSettings = class extends Array {
|
|
|
722
726
|
}
|
|
723
727
|
};
|
|
724
728
|
function createObjectSettings(args) {
|
|
725
|
-
var _a, _b, _c, _d;
|
|
729
|
+
var _a, _b, _c, _d, _e;
|
|
726
730
|
const { config, text } = args;
|
|
727
731
|
const result = new ObjectSettings();
|
|
728
732
|
const textLines = text.split("\n");
|
|
@@ -740,6 +744,7 @@ function createObjectSettings(args) {
|
|
|
740
744
|
arguments: [],
|
|
741
745
|
input: false,
|
|
742
746
|
output: false,
|
|
747
|
+
model: false,
|
|
743
748
|
from: ""
|
|
744
749
|
};
|
|
745
750
|
if (name === "TypeGraphQL.omit" || name === "HideField") {
|
|
@@ -747,9 +752,6 @@ function createObjectSettings(args) {
|
|
|
747
752
|
} else if (["FieldType", "PropertyType"].includes(name) && ((_b = match.groups) == null ? void 0 : _b.args)) {
|
|
748
753
|
const options = customType(match.groups.args);
|
|
749
754
|
(0, import_lodash4.merge)(element, options.namespace && config.fields[options.namespace], options, { kind: name });
|
|
750
|
-
} else if (name === "IsAbstract") {
|
|
751
|
-
element.kind = "ObjectType";
|
|
752
|
-
element.arguments = { isAbstract: true };
|
|
753
755
|
} else if (name === "ObjectType" && ((_c = match.groups) == null ? void 0 : _c.args)) {
|
|
754
756
|
element.kind = "ObjectType";
|
|
755
757
|
const options = customType(match.groups.args);
|
|
@@ -763,14 +765,22 @@ function createObjectSettings(args) {
|
|
|
763
765
|
name: options.name,
|
|
764
766
|
isAbstract: options.isAbstract
|
|
765
767
|
};
|
|
768
|
+
} else if (name === "Directive" && ((_d = match.groups) == null ? void 0 : _d.args)) {
|
|
769
|
+
const options = customType(match.groups.args);
|
|
770
|
+
(0, import_lodash4.merge)(element, { model: true, from: "@nestjs/graphql" }, options, {
|
|
771
|
+
name,
|
|
772
|
+
namespace: false,
|
|
773
|
+
kind: "Decorator",
|
|
774
|
+
arguments: Array.isArray(options.arguments) ? options.arguments.map((s) => import_json52.default.stringify(s)) : options.arguments
|
|
775
|
+
});
|
|
766
776
|
} else {
|
|
767
777
|
const namespace = getNamespace(name);
|
|
768
778
|
element.namespaceImport = namespace;
|
|
769
779
|
const options = {
|
|
770
780
|
name,
|
|
771
|
-
arguments: (((
|
|
781
|
+
arguments: (((_e = match.groups) == null ? void 0 : _e.args) || "").split(",").map((s) => (0, import_lodash4.trim)(s)).filter(Boolean)
|
|
772
782
|
};
|
|
773
|
-
(0, import_lodash4.merge)(element, config.fields[namespace], options);
|
|
783
|
+
(0, import_lodash4.merge)(element, namespace && config.fields[namespace], options);
|
|
774
784
|
}
|
|
775
785
|
result.push(element);
|
|
776
786
|
}
|
|
@@ -840,6 +850,9 @@ function parseArgs(string) {
|
|
|
840
850
|
}
|
|
841
851
|
}
|
|
842
852
|
function getNamespace(name) {
|
|
853
|
+
if (name === void 0) {
|
|
854
|
+
return void 0;
|
|
855
|
+
}
|
|
843
856
|
let result = String(name);
|
|
844
857
|
if (result.includes(".")) {
|
|
845
858
|
[result] = result.split(".");
|
|
@@ -884,7 +897,7 @@ function getOutputTypeName(name) {
|
|
|
884
897
|
// src/handlers/model-output-type.ts
|
|
885
898
|
var nestjsGraphql = "@nestjs/graphql";
|
|
886
899
|
function modelOutputType(outputType2, args) {
|
|
887
|
-
var _a, _b, _c, _d, _e;
|
|
900
|
+
var _a, _b, _c, _d, _e, _f;
|
|
888
901
|
const { getSourceFile, models, config, modelFields, fieldSettings, eventEmitter } = args;
|
|
889
902
|
const model = models.get(outputType2.name);
|
|
890
903
|
(0, import_assert3.ok)(model, `Cannot find model by name ${outputType2.name}`);
|
|
@@ -908,8 +921,10 @@ function modelOutputType(outputType2, args) {
|
|
|
908
921
|
properties: []
|
|
909
922
|
};
|
|
910
923
|
sourceFileStructure.statements.push(classStructure);
|
|
911
|
-
|
|
924
|
+
(0, import_assert3.ok)(classStructure.decorators, "classStructure.decorators is undefined");
|
|
925
|
+
const decorator = classStructure.decorators.find((d) => d.name === "ObjectType");
|
|
912
926
|
(0, import_assert3.ok)(decorator, "ObjectType decorator not found");
|
|
927
|
+
let modelSettings;
|
|
913
928
|
if (model.documentation) {
|
|
914
929
|
const objectTypeOptions = {};
|
|
915
930
|
const { documentation, settings } = createObjectSettings({
|
|
@@ -924,6 +939,7 @@ function modelOutputType(outputType2, args) {
|
|
|
924
939
|
objectTypeOptions.description = documentation;
|
|
925
940
|
}
|
|
926
941
|
decorator.arguments = settings.getObjectTypeArguments(objectTypeOptions);
|
|
942
|
+
modelSettings = settings;
|
|
927
943
|
}
|
|
928
944
|
importDeclarations.add("Field", nestjsGraphql);
|
|
929
945
|
importDeclarations.add("ObjectType", nestjsGraphql);
|
|
@@ -935,8 +951,8 @@ function modelOutputType(outputType2, args) {
|
|
|
935
951
|
fileType = "output";
|
|
936
952
|
outputTypeName = getOutputTypeName(outputTypeName);
|
|
937
953
|
}
|
|
938
|
-
const modelField = (
|
|
939
|
-
const settings = (
|
|
954
|
+
const modelField = (_a = modelFields.get(model.name)) == null ? void 0 : _a.get(field.name);
|
|
955
|
+
const settings = (_b = fieldSettings.get(model.name)) == null ? void 0 : _b.get(field.name);
|
|
940
956
|
const fieldType = settings == null ? void 0 : settings.getFieldType({
|
|
941
957
|
name: outputType2.name,
|
|
942
958
|
output: true
|
|
@@ -984,7 +1000,7 @@ function modelOutputType(outputType2, args) {
|
|
|
984
1000
|
property.leadingTrivia += `/** ${modelField.documentation} */
|
|
985
1001
|
`;
|
|
986
1002
|
}
|
|
987
|
-
(
|
|
1003
|
+
(_c = classStructure.properties) == null ? void 0 : _c.push(property);
|
|
988
1004
|
if (propertySettings) {
|
|
989
1005
|
importDeclarations.create(__spreadValues({}, propertySettings));
|
|
990
1006
|
}
|
|
@@ -1004,22 +1020,21 @@ function modelOutputType(outputType2, args) {
|
|
|
1004
1020
|
})
|
|
1005
1021
|
]
|
|
1006
1022
|
});
|
|
1007
|
-
for (const
|
|
1008
|
-
if (
|
|
1009
|
-
|
|
1023
|
+
for (const setting of settings || []) {
|
|
1024
|
+
if (shouldBeDecorated(setting) && ((_e = (_d = setting.match) == null ? void 0 : _d.call(setting, field.name)) != null ? _e : true)) {
|
|
1025
|
+
property.decorators.push({
|
|
1026
|
+
name: setting.name,
|
|
1027
|
+
arguments: setting.arguments
|
|
1028
|
+
});
|
|
1029
|
+
(0, import_assert3.ok)(setting.from, "Missed 'from' part in configuration or field setting");
|
|
1030
|
+
importDeclarations.create(setting);
|
|
1010
1031
|
}
|
|
1011
|
-
property.decorators.push({
|
|
1012
|
-
name: options.name,
|
|
1013
|
-
arguments: options.arguments
|
|
1014
|
-
});
|
|
1015
|
-
(0, import_assert3.ok)(options.from, "Missed 'from' part in configuration or field setting");
|
|
1016
|
-
importDeclarations.create(options);
|
|
1017
1032
|
}
|
|
1018
1033
|
for (const decorate of config.decorate) {
|
|
1019
1034
|
if (decorate.isMatchField(field.name) && decorate.isMatchType(outputTypeName)) {
|
|
1020
1035
|
property.decorators.push({
|
|
1021
1036
|
name: decorate.name,
|
|
1022
|
-
arguments: (
|
|
1037
|
+
arguments: (_f = decorate.arguments) == null ? void 0 : _f.map((x) => (0, import_pupa2.default)(x, { propertyType }))
|
|
1023
1038
|
});
|
|
1024
1039
|
importDeclarations.create(decorate);
|
|
1025
1040
|
}
|
|
@@ -1031,6 +1046,15 @@ function modelOutputType(outputType2, args) {
|
|
|
1031
1046
|
propertyType
|
|
1032
1047
|
});
|
|
1033
1048
|
}
|
|
1049
|
+
for (const setting of modelSettings || []) {
|
|
1050
|
+
if (shouldBeDecorated(setting)) {
|
|
1051
|
+
classStructure.decorators.push({
|
|
1052
|
+
name: setting.name,
|
|
1053
|
+
arguments: setting.arguments
|
|
1054
|
+
});
|
|
1055
|
+
importDeclarations.create(setting);
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1034
1058
|
if (exportDeclaration) {
|
|
1035
1059
|
sourceFile.set({
|
|
1036
1060
|
statements: [exportDeclaration, "\n", classStructure]
|
|
@@ -1045,6 +1069,9 @@ function modelOutputType(outputType2, args) {
|
|
|
1045
1069
|
});
|
|
1046
1070
|
}
|
|
1047
1071
|
}
|
|
1072
|
+
function shouldBeDecorated(setting) {
|
|
1073
|
+
return setting.kind === "Decorator" && (setting.output || setting.model) && !(setting.output && setting.model);
|
|
1074
|
+
}
|
|
1048
1075
|
function getExportDeclaration(name, statements) {
|
|
1049
1076
|
return statements.find((structure) => {
|
|
1050
1077
|
return structure.kind === import_ts_morph5.StructureKind.ExportDeclaration && structure.namedExports.some((o) => (o.alias || o.name) === name);
|
|
@@ -1088,7 +1115,7 @@ var import_lodash6 = __toModule(require("lodash"));
|
|
|
1088
1115
|
var import_ts_morph6 = __toModule(require("ts-morph"));
|
|
1089
1116
|
var nestjsGraphql2 = "@nestjs/graphql";
|
|
1090
1117
|
function outputType(outputType2, args) {
|
|
1091
|
-
var _a, _b, _c;
|
|
1118
|
+
var _a, _b, _c, _d, _e;
|
|
1092
1119
|
const { getSourceFile, models, eventEmitter, fieldSettings, getModelName: getModelName2 } = args;
|
|
1093
1120
|
const importDeclarations = new ImportDeclarationMap();
|
|
1094
1121
|
const fileType = "output";
|
|
@@ -1142,36 +1169,44 @@ function outputType(outputType2, args) {
|
|
|
1142
1169
|
if (propertySettings) {
|
|
1143
1170
|
importDeclarations.create(__spreadValues({}, propertySettings));
|
|
1144
1171
|
}
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1172
|
+
let graphqlType;
|
|
1173
|
+
const shouldHideField = settings == null ? void 0 : settings.shouldHideField({
|
|
1174
|
+
name: outputType2.name,
|
|
1175
|
+
output: true
|
|
1176
|
+
});
|
|
1177
|
+
const fieldType = settings == null ? void 0 : settings.getFieldType({
|
|
1178
|
+
name: outputType2.name,
|
|
1179
|
+
output: true
|
|
1180
|
+
});
|
|
1181
|
+
if (fieldType && isCustomsApplicable && !shouldHideField) {
|
|
1182
|
+
graphqlType = fieldType.name;
|
|
1183
|
+
importDeclarations.create(__spreadValues({}, fieldType));
|
|
1149
1184
|
} else {
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1185
|
+
const graphqlImport = getGraphqlImport({
|
|
1186
|
+
sourceFile,
|
|
1187
|
+
fileType,
|
|
1188
|
+
location,
|
|
1189
|
+
isId: false,
|
|
1190
|
+
typeName: outputTypeName,
|
|
1191
|
+
getSourceFile
|
|
1154
1192
|
});
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
typeName: outputTypeName,
|
|
1165
|
-
getSourceFile
|
|
1193
|
+
graphqlType = graphqlImport.name;
|
|
1194
|
+
let referenceName = propertyType[0];
|
|
1195
|
+
if (location === "enumTypes") {
|
|
1196
|
+
referenceName = (0, import_lodash6.last)(referenceName.split(" "));
|
|
1197
|
+
}
|
|
1198
|
+
if (graphqlImport.specifier && !importDeclarations.has(graphqlImport.name) && (graphqlImport.name !== outputType2.name && !shouldHideField || shouldHideField && referenceName === graphqlImport.name)) {
|
|
1199
|
+
importDeclarations.set(graphqlImport.name, {
|
|
1200
|
+
namedImports: [{ name: graphqlImport.name }],
|
|
1201
|
+
moduleSpecifier: graphqlImport.specifier
|
|
1166
1202
|
});
|
|
1167
|
-
graphqlType = graphqlImport.name;
|
|
1168
|
-
if (graphqlImport.name !== outputType2.name && graphqlImport.specifier && !importDeclarations.has(graphqlImport.name)) {
|
|
1169
|
-
importDeclarations.set(graphqlImport.name, {
|
|
1170
|
-
namedImports: [{ name: graphqlImport.name }],
|
|
1171
|
-
moduleSpecifier: graphqlImport.specifier
|
|
1172
|
-
});
|
|
1173
|
-
}
|
|
1174
1203
|
}
|
|
1204
|
+
}
|
|
1205
|
+
(0, import_assert4.ok)(property.decorators, "property.decorators is undefined");
|
|
1206
|
+
if (shouldHideField) {
|
|
1207
|
+
importDeclarations.add("HideField", nestjsGraphql2);
|
|
1208
|
+
property.decorators.push({ name: "HideField", arguments: [] });
|
|
1209
|
+
} else {
|
|
1175
1210
|
property.decorators.push({
|
|
1176
1211
|
name: "Field",
|
|
1177
1212
|
arguments: [
|
|
@@ -1183,15 +1218,14 @@ function outputType(outputType2, args) {
|
|
|
1183
1218
|
});
|
|
1184
1219
|
if (isCustomsApplicable) {
|
|
1185
1220
|
for (const options of settings || []) {
|
|
1186
|
-
if (
|
|
1187
|
-
|
|
1221
|
+
if ((_e = options.kind === "Decorator" && options.output && ((_d = options.match) == null ? void 0 : _d.call(options, field.name))) != null ? _e : true) {
|
|
1222
|
+
property.decorators.push({
|
|
1223
|
+
name: options.name,
|
|
1224
|
+
arguments: options.arguments
|
|
1225
|
+
});
|
|
1226
|
+
(0, import_assert4.ok)(options.from, "Missed 'from' part in configuration or field setting");
|
|
1227
|
+
importDeclarations.create(options);
|
|
1188
1228
|
}
|
|
1189
|
-
property.decorators.push({
|
|
1190
|
-
name: options.name,
|
|
1191
|
-
arguments: options.arguments
|
|
1192
|
-
});
|
|
1193
|
-
(0, import_assert4.ok)(options.from, "Missed 'from' part in configuration or field setting");
|
|
1194
|
-
importDeclarations.create(options);
|
|
1195
1229
|
}
|
|
1196
1230
|
}
|
|
1197
1231
|
}
|
|
@@ -1381,6 +1415,7 @@ function createConfig(data) {
|
|
|
1381
1415
|
arguments: [],
|
|
1382
1416
|
output: toBoolean(value.output),
|
|
1383
1417
|
input: toBoolean(value.input),
|
|
1418
|
+
model: toBoolean(value.model),
|
|
1384
1419
|
from: value.from,
|
|
1385
1420
|
defaultImport: toBoolean(value.defaultImport) ? true : value.defaultImport,
|
|
1386
1421
|
namespaceImport: value.namespaceImport
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prisma-nestjs-graphql",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.6.1",
|
|
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",
|
|
@@ -44,10 +44,14 @@
|
|
|
44
44
|
"config": {
|
|
45
45
|
"commitizen": {
|
|
46
46
|
"path": "node_modules/cz-customizable"
|
|
47
|
+
},
|
|
48
|
+
"ghooks": {
|
|
49
|
+
"pre-commit": "precise-commits",
|
|
50
|
+
"commit-msg": "sh Taskfile commit_lint"
|
|
47
51
|
}
|
|
48
52
|
},
|
|
49
53
|
"dependencies": {
|
|
50
|
-
"@prisma/generator-helper": "^3.
|
|
54
|
+
"@prisma/generator-helper": "^3.5.0",
|
|
51
55
|
"await-event-emitter": "^2.0.2",
|
|
52
56
|
"filenamify": "4.X",
|
|
53
57
|
"flat": "^5.0.2",
|
|
@@ -57,68 +61,66 @@
|
|
|
57
61
|
"outmatch": "^0.7.0",
|
|
58
62
|
"pluralize": "^8.0.0",
|
|
59
63
|
"pupa": "2.X",
|
|
60
|
-
"ts-morph": ">=11
|
|
64
|
+
"ts-morph": ">=11"
|
|
61
65
|
},
|
|
62
66
|
"devDependencies": {
|
|
63
|
-
"@
|
|
64
|
-
"@commitlint/
|
|
65
|
-
"@
|
|
66
|
-
"@nestjs/
|
|
67
|
-
"@nestjs/
|
|
68
|
-
"@nestjs/
|
|
69
|
-
"@nestjs/platform-express": "^8.0.6",
|
|
67
|
+
"@commitlint/cli": "^15.0.0",
|
|
68
|
+
"@commitlint/config-conventional": "^15.0.0",
|
|
69
|
+
"@nestjs/common": "^8.2.3",
|
|
70
|
+
"@nestjs/core": "^8.2.3",
|
|
71
|
+
"@nestjs/graphql": "^9.1.2",
|
|
72
|
+
"@nestjs/platform-express": "^8.2.3",
|
|
70
73
|
"@paljs/plugins": "^4.0.8",
|
|
71
|
-
"@prisma/client": "^3.
|
|
72
|
-
"@semantic-release/changelog": "^6.0.
|
|
73
|
-
"@semantic-release/git": "^10.0.
|
|
74
|
+
"@prisma/client": "^3.5.0",
|
|
75
|
+
"@semantic-release/changelog": "^6.0.1",
|
|
76
|
+
"@semantic-release/git": "^10.0.1",
|
|
74
77
|
"@types/flat": "^5.0.2",
|
|
75
|
-
"@types/lodash": "^4.14.
|
|
78
|
+
"@types/lodash": "^4.14.177",
|
|
76
79
|
"@types/mocha": "^9.0.0",
|
|
77
|
-
"@types/node": "^16.
|
|
80
|
+
"@types/node": "^16.11.10",
|
|
78
81
|
"@types/pluralize": "^0.0.29",
|
|
79
|
-
"@typescript-eslint/eslint-plugin": "^4.
|
|
80
|
-
"@typescript-eslint/parser": "^4.
|
|
81
|
-
"apollo-server-express": "^3.
|
|
82
|
-
"c8": "^7.
|
|
83
|
-
"class-transformer": "^0.
|
|
84
|
-
"class-validator": "^0.13.
|
|
82
|
+
"@typescript-eslint/eslint-plugin": "^5.4.0",
|
|
83
|
+
"@typescript-eslint/parser": "^5.4.0",
|
|
84
|
+
"apollo-server-express": "^3.5.0",
|
|
85
|
+
"c8": "^7.10.0",
|
|
86
|
+
"class-transformer": "^0.5.1",
|
|
87
|
+
"class-validator": "^0.13.2",
|
|
85
88
|
"commitizen": "^4.2.4",
|
|
86
89
|
"cz-customizable": "^6.3.0",
|
|
87
90
|
"decimal.js": "^10.3.1",
|
|
88
|
-
"eslint": "^
|
|
91
|
+
"eslint": "^8.3.0",
|
|
89
92
|
"eslint-import-resolver-node": "^0.3.6",
|
|
90
|
-
"eslint-plugin-etc": "^
|
|
91
|
-
"eslint-plugin-import": "^2.
|
|
93
|
+
"eslint-plugin-etc": "^2.0.1",
|
|
94
|
+
"eslint-plugin-import": "^2.25.3",
|
|
92
95
|
"eslint-plugin-only-warn": "^1.0.3",
|
|
93
96
|
"eslint-plugin-prettier": "^4.0.0",
|
|
94
|
-
"eslint-plugin-
|
|
95
|
-
"eslint-plugin-regexp": "^1.1.0",
|
|
97
|
+
"eslint-plugin-regexp": "^1.5.1",
|
|
96
98
|
"eslint-plugin-simple-import-sort": "^7.0.0",
|
|
97
|
-
"eslint-plugin-
|
|
98
|
-
"eslint-plugin-
|
|
99
|
-
"eslint-plugin-total-functions": "^4.10.1",
|
|
100
|
-
"eslint-plugin-unicorn": "^36.0.0",
|
|
99
|
+
"eslint-plugin-sort-class-members": "^1.14.0",
|
|
100
|
+
"eslint-plugin-unicorn": "^39.0.0",
|
|
101
101
|
"eslint-plugin-wix-editor": "^3.3.0",
|
|
102
|
-
"expect": "^27.
|
|
102
|
+
"expect": "^27.3.1",
|
|
103
|
+
"ghooks": "^2.0.4",
|
|
103
104
|
"git-branch-is": "^4.0.0",
|
|
104
|
-
"graphql": "^15.
|
|
105
|
-
"graphql-scalars": "^1.
|
|
105
|
+
"graphql": "^15.7.2",
|
|
106
|
+
"graphql-scalars": "^1.13.6",
|
|
106
107
|
"graphql-type-json": "^0.3.2",
|
|
107
|
-
"mocha": "^9.1.
|
|
108
|
+
"mocha": "^9.1.3",
|
|
108
109
|
"ololog": "^1.1.175",
|
|
109
110
|
"precise-commits": "^1.0.2",
|
|
110
|
-
"prettier": "^2.
|
|
111
|
-
"prisma": "^3.
|
|
111
|
+
"prettier": "^2.5.0",
|
|
112
|
+
"prisma": "^3.5.0",
|
|
112
113
|
"prisma-graphql-type-decimal": "^1.0.0",
|
|
113
114
|
"reflect-metadata": "^0.1.13",
|
|
114
|
-
"
|
|
115
|
-
"
|
|
115
|
+
"request": "^2.88.2",
|
|
116
|
+
"rxjs": "^7.4.0",
|
|
117
|
+
"semantic-release": "^18.0.1",
|
|
116
118
|
"simplytyped": "^3.3.0",
|
|
117
119
|
"temp-dir": "^2.0.0",
|
|
118
|
-
"ts-node": "^10.
|
|
120
|
+
"ts-node": "^10.4.0",
|
|
119
121
|
"ts-node-dev": "^1.1.8",
|
|
120
122
|
"tslib": "^2.3.1",
|
|
121
|
-
"typescript": "^4.
|
|
123
|
+
"typescript": "^4.5.2",
|
|
122
124
|
"watchexec-bin": "^1.0.0"
|
|
123
125
|
}
|
|
124
126
|
}
|