prisma-nestjs-graphql 15.0.0 → 15.2.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 +3 -23
- package/bin.js +2 -0
- package/index.js +30 -3
- package/package.json +18 -18
package/README.md
CHANGED
|
@@ -21,6 +21,8 @@ npm install --save-dev prisma-nestjs-graphql
|
|
|
21
21
|
```prisma
|
|
22
22
|
generator nestgraphql {
|
|
23
23
|
provider = "node node_modules/prisma-nestjs-graphql"
|
|
24
|
+
// for yarn monorepos
|
|
25
|
+
// provider = "prisma-nestjs-graphql"
|
|
24
26
|
output = "../src/@generated/prisma-nestjs-graphql"
|
|
25
27
|
}
|
|
26
28
|
```
|
|
@@ -556,29 +558,7 @@ Similar to `@FieldType()` but refer to TypeScript property (actually field too).
|
|
|
556
558
|
To override TypeScript type in specific classes, you can use glob pattern `match: string | string[]`
|
|
557
559
|
see [outmatch](https://github.com/axtgr/outmatch#usage) for details.
|
|
558
560
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
```prisma
|
|
562
|
-
model Transfer {
|
|
563
|
-
id String @id
|
|
564
|
-
/// @PropertyType({ name: 'Prisma.Decimal', from: '@prisma/client', namedImport: true, input: true })
|
|
565
|
-
money Decimal
|
|
566
|
-
}
|
|
567
|
-
```
|
|
568
|
-
|
|
569
|
-
May generate following:
|
|
570
|
-
|
|
571
|
-
```ts
|
|
572
|
-
import { Prisma } from '@prisma/client';
|
|
573
|
-
|
|
574
|
-
@ObjectType()
|
|
575
|
-
export class TransferCreateInput {
|
|
576
|
-
@Field(() => GraphQLDecimal)
|
|
577
|
-
money!: Prisma.Decimal;
|
|
578
|
-
}
|
|
579
|
-
```
|
|
580
|
-
|
|
581
|
-
Another example:
|
|
561
|
+
Example:
|
|
582
562
|
|
|
583
563
|
```
|
|
584
564
|
generator nestgraphql {
|
package/bin.js
ADDED
package/index.js
CHANGED
|
@@ -541,6 +541,9 @@ function getPropertyType(args) {
|
|
|
541
541
|
"string"
|
|
542
542
|
];
|
|
543
543
|
case "Decimal":
|
|
544
|
+
return [
|
|
545
|
+
"Decimal"
|
|
546
|
+
];
|
|
544
547
|
case "Json":
|
|
545
548
|
return [
|
|
546
549
|
"any"
|
|
@@ -669,6 +672,8 @@ function inputType(args) {
|
|
|
669
672
|
importDeclarations.create({
|
|
670
673
|
...propertySettings
|
|
671
674
|
});
|
|
675
|
+
} else if (!propertySettings && propertyType.includes("Decimal")) {
|
|
676
|
+
importDeclarations.add("Decimal", "@prisma/client/runtime");
|
|
672
677
|
}
|
|
673
678
|
let graphqlType;
|
|
674
679
|
const shouldHideField = settings == null ? void 0 : settings.shouldHideField({
|
|
@@ -1118,6 +1123,8 @@ function modelOutputType(outputType2, args) {
|
|
|
1118
1123
|
importDeclarations.create({
|
|
1119
1124
|
...propertySettings
|
|
1120
1125
|
});
|
|
1126
|
+
} else if (!propertySettings && propertyType.includes("Decimal")) {
|
|
1127
|
+
importDeclarations.add("Decimal", "@prisma/client/runtime");
|
|
1121
1128
|
}
|
|
1122
1129
|
(0, import_assert3.ok)(property.decorators, "property.decorators is undefined");
|
|
1123
1130
|
if (settings == null ? void 0 : settings.shouldHideField({
|
|
@@ -1312,6 +1319,8 @@ function outputType(outputType1, args) {
|
|
|
1312
1319
|
importDeclarations.create({
|
|
1313
1320
|
...propertySettings
|
|
1314
1321
|
});
|
|
1322
|
+
} else if (!propertySettings && propertyType.includes("Decimal")) {
|
|
1323
|
+
importDeclarations.add("Decimal", "@prisma/client/runtime");
|
|
1315
1324
|
}
|
|
1316
1325
|
let graphqlType;
|
|
1317
1326
|
const shouldHideField = settings == null ? void 0 : settings.shouldHideField({
|
|
@@ -1442,12 +1451,24 @@ function beforeGenerateFiles2(args) {
|
|
|
1442
1451
|
ReExport.Directories,
|
|
1443
1452
|
ReExport.All
|
|
1444
1453
|
].includes(config.reExport)) {
|
|
1445
|
-
for (const directory of rootDirectory.
|
|
1454
|
+
for (const directory of rootDirectory.getDescendantDirectories()) {
|
|
1455
|
+
let indexSourceFile;
|
|
1446
1456
|
const exportDeclarations = directory.getSourceFiles().filter((sourceFile) => {
|
|
1447
1457
|
return sourceFile.getBaseName() !== "index.ts";
|
|
1448
1458
|
}).map((sourcesFile) => getExportDeclaration2(directory, sourcesFile));
|
|
1449
|
-
|
|
1450
|
-
|
|
1459
|
+
if (exportDeclarations.length > 0) {
|
|
1460
|
+
indexSourceFile = directory.createSourceFile("index.ts", {
|
|
1461
|
+
statements: exportDeclarations
|
|
1462
|
+
}, {
|
|
1463
|
+
overwrite: true
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1466
|
+
if (indexSourceFile) {
|
|
1467
|
+
continue;
|
|
1468
|
+
}
|
|
1469
|
+
const namespaceExportDeclarations = directory.getDirectories().map((sourceDirectory) => getNamespaceExportDeclaration(directory, sourceDirectory));
|
|
1470
|
+
project.createSourceFile(`${directory.getPath()}/index.ts`, {
|
|
1471
|
+
statements: namespaceExportDeclarations
|
|
1451
1472
|
}, {
|
|
1452
1473
|
overwrite: true
|
|
1453
1474
|
});
|
|
@@ -1487,6 +1508,12 @@ function getExportDeclaration2(directory, sourceFile) {
|
|
|
1487
1508
|
};
|
|
1488
1509
|
}
|
|
1489
1510
|
__name(getExportDeclaration2, "getExportDeclaration");
|
|
1511
|
+
function getNamespaceExportDeclaration(directory, sourceDirectory) {
|
|
1512
|
+
return {
|
|
1513
|
+
kind: import_ts_morph7.StructureKind.ExportDeclaration,
|
|
1514
|
+
moduleSpecifier: directory.getRelativePathAsModuleSpecifierTo(sourceDirectory)
|
|
1515
|
+
};
|
|
1516
|
+
}
|
|
1490
1517
|
|
|
1491
1518
|
// src/handlers/register-enum.ts
|
|
1492
1519
|
var import_ts_morph8 = require("ts-morph");
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prisma-nestjs-graphql",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.2.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",
|
|
7
|
-
"bin": "
|
|
7
|
+
"bin": "bin.js",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+https://github.com/unlight/nestjs-graphql-prisma.git"
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@nestjs/apollo": "^10.0.
|
|
55
|
-
"@prisma/generator-helper": "^3.
|
|
54
|
+
"@nestjs/apollo": "^10.0.7",
|
|
55
|
+
"@prisma/generator-helper": "^3.11.0",
|
|
56
56
|
"await-event-emitter": "^2.0.2",
|
|
57
57
|
"filenamify": "4.X",
|
|
58
58
|
"flat": "^5.0.2",
|
|
@@ -65,26 +65,26 @@
|
|
|
65
65
|
"ts-morph": ">=11"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@commitlint/cli": "^16.2.
|
|
68
|
+
"@commitlint/cli": "^16.2.3",
|
|
69
69
|
"@commitlint/config-conventional": "^16.2.1",
|
|
70
|
-
"@nestjs/common": "^8.4.
|
|
71
|
-
"@nestjs/core": "^8.4.
|
|
72
|
-
"@nestjs/graphql": "^10.0.
|
|
73
|
-
"@nestjs/platform-express": "^8.4.
|
|
74
|
-
"@paljs/plugins": "^4.0.
|
|
75
|
-
"@prisma/client": "^3.
|
|
70
|
+
"@nestjs/common": "^8.4.1",
|
|
71
|
+
"@nestjs/core": "^8.4.1",
|
|
72
|
+
"@nestjs/graphql": "^10.0.7",
|
|
73
|
+
"@nestjs/platform-express": "^8.4.1",
|
|
74
|
+
"@paljs/plugins": "^4.0.18",
|
|
75
|
+
"@prisma/client": "^3.11.0",
|
|
76
76
|
"@semantic-release/changelog": "^6.0.1",
|
|
77
77
|
"@semantic-release/git": "^10.0.1",
|
|
78
|
-
"@swc/core": "^1.2.
|
|
79
|
-
"@swc/helpers": "^0.3.
|
|
78
|
+
"@swc/core": "^1.2.156",
|
|
79
|
+
"@swc/helpers": "^0.3.8",
|
|
80
80
|
"@swc/register": "^0.1.10",
|
|
81
81
|
"@types/flat": "^5.0.2",
|
|
82
|
-
"@types/lodash": "^4.14.
|
|
82
|
+
"@types/lodash": "^4.14.180",
|
|
83
83
|
"@types/mocha": "^9.1.0",
|
|
84
84
|
"@types/node": "^17.0.21",
|
|
85
85
|
"@types/pluralize": "^0.0.29",
|
|
86
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
87
|
-
"@typescript-eslint/parser": "^5.
|
|
86
|
+
"@typescript-eslint/eslint-plugin": "^5.15.0",
|
|
87
|
+
"@typescript-eslint/parser": "^5.15.0",
|
|
88
88
|
"apollo-server-express": "^3.6.4",
|
|
89
89
|
"c8": "^7.11.0",
|
|
90
90
|
"class-transformer": "^0.5.1",
|
|
@@ -112,8 +112,8 @@
|
|
|
112
112
|
"mocha": "^9.2.2",
|
|
113
113
|
"ololog": "^1.1.175",
|
|
114
114
|
"precise-commits": "^1.0.2",
|
|
115
|
-
"prettier": "^2.
|
|
116
|
-
"prisma": "^3.
|
|
115
|
+
"prettier": "^2.6.0",
|
|
116
|
+
"prisma": "^3.11.0",
|
|
117
117
|
"prisma-graphql-type-decimal": "^2.0.0",
|
|
118
118
|
"reflect-metadata": "^0.1.13",
|
|
119
119
|
"request": "^2.88.2",
|