prisma-nestjs-graphql 21.0.2 → 21.1.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 +44 -18
- package/generate.cjs +23 -1
- package/generate.d.ts +8 -0
- package/package.json +3 -1
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -361,6 +361,28 @@ export class BigIntFilter {
|
|
|
361
361
|
|
|
362
362
|
It will affect all inputs and outputs types (including models).
|
|
363
363
|
|
|
364
|
+
#### `customImport`
|
|
365
|
+
|
|
366
|
+
Allow to declare custom import statements. (Only works with emitSingle = true)
|
|
367
|
+
|
|
368
|
+
```sh
|
|
369
|
+
generator nestgraphql {
|
|
370
|
+
customImport_{key}_from = "module specifier"
|
|
371
|
+
customImport_{key}_name = "import name"
|
|
372
|
+
customImport_{key}_defaultImport = "default import name" | true
|
|
373
|
+
customImport_{key}_namespaceImport = "namespace import name"
|
|
374
|
+
customImport_{key}_namedImport = "import name" | true
|
|
375
|
+
}
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
Where `{key}` any identifier to group values (written in [flatten](https://github.com/hughsk/flat) style)
|
|
379
|
+
|
|
380
|
+
- `customImport_{key}_from` - module specifier to import from (e.g `nestjs-i18n`)
|
|
381
|
+
- `customImport_{key}_name` - import name or name with namespace
|
|
382
|
+
- `customImport_{key}_defaultImport` - import as default
|
|
383
|
+
- `customImport_{key}_namespaceImport` - use this name as import namespace
|
|
384
|
+
- `customImport_{key}_namedImport` - named import (without namespace)
|
|
385
|
+
|
|
364
386
|
## Documentation and field options
|
|
365
387
|
|
|
366
388
|
Comments with triple slash will projected to typescript code comments
|
|
@@ -736,27 +758,27 @@ import { generate } from 'prisma-nestjs-graphql/generate';
|
|
|
736
758
|
|
|
737
759
|
## Similar Projects
|
|
738
760
|
|
|
739
|
-
- https://github.com/jasonraimondi/prisma-generator-nestjs-graphql
|
|
740
|
-
- https://github.com/omar-dulaimi/prisma-class-validator-generator
|
|
741
|
-
- https://github.com/kimjbstar/prisma-class-generator
|
|
742
|
-
- https://github.com/odroe/nest-gql-mix
|
|
743
|
-
- https://github.com/rfermann/nestjs-prisma-graphql-generator
|
|
744
|
-
- https://github.com/madscience/graphql-codegen-nestjs
|
|
745
|
-
- https://github.com/wSedlacek/prisma-generators/tree/master/libs/nestjs
|
|
746
|
-
- https://github.com/EndyKaufman/typegraphql-prisma-nestjs
|
|
747
|
-
- https://github.com/MichalLytek/typegraphql-prisma
|
|
748
|
-
- https://github.com/mk668a/nestjs-prisma-graphql-crud-gen
|
|
761
|
+
- <https://github.com/jasonraimondi/prisma-generator-nestjs-graphql>
|
|
762
|
+
- <https://github.com/omar-dulaimi/prisma-class-validator-generator>
|
|
763
|
+
- <https://github.com/kimjbstar/prisma-class-generator>
|
|
764
|
+
- <https://github.com/odroe/nest-gql-mix>
|
|
765
|
+
- <https://github.com/rfermann/nestjs-prisma-graphql-generator>
|
|
766
|
+
- <https://github.com/madscience/graphql-codegen-nestjs>
|
|
767
|
+
- <https://github.com/wSedlacek/prisma-generators/tree/master/libs/nestjs>
|
|
768
|
+
- <https://github.com/EndyKaufman/typegraphql-prisma-nestjs>
|
|
769
|
+
- <https://github.com/MichalLytek/typegraphql-prisma>
|
|
770
|
+
- <https://github.com/mk668a/nestjs-prisma-graphql-crud-gen>
|
|
749
771
|
|
|
750
772
|
## Resources
|
|
751
773
|
|
|
752
|
-
- Todo - https://github.com/unlight/prisma-nestjs-graphql/issues/2
|
|
753
|
-
- https://github.com/prisma/prisma/blob/main/packages/client/src/generation/TSClient/TSClient.ts
|
|
754
|
-
- https://ts-ast-viewer.com
|
|
755
|
-
- https://github.com/unlight/nestjs-graphql-prisma-realworld-example-app
|
|
756
|
-
- https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-schema/data-model
|
|
757
|
-
- JSON type for the code first approach - https://github.com/nestjs/graphql/issues/111#issuecomment-631452899
|
|
758
|
-
- https://github.com/paljs/prisma-tools/tree/master/packages/plugins
|
|
759
|
-
- https://github.com/wasp-lang/wasp
|
|
774
|
+
- Todo - <https://github.com/unlight/prisma-nestjs-graphql/issues/2>
|
|
775
|
+
- <https://github.com/prisma/prisma/blob/main/packages/client/src/generation/TSClient/TSClient.ts>
|
|
776
|
+
- <https://ts-ast-viewer.com/>
|
|
777
|
+
- <https://github.com/unlight/nestjs-graphql-prisma-realworld-example-app>
|
|
778
|
+
- <https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-schema/data-model>
|
|
779
|
+
- JSON type for the code first approach - <https://github.com/nestjs/graphql/issues/111#issuecomment-631452899>
|
|
780
|
+
- <https://github.com/paljs/prisma-tools/tree/master/packages/plugins>
|
|
781
|
+
- <https://github.com/wasp-lang/wasp>
|
|
760
782
|
|
|
761
783
|
## TODO
|
|
762
784
|
|
|
@@ -764,3 +786,7 @@ import { generate } from 'prisma-nestjs-graphql/generate';
|
|
|
764
786
|
- dummy-createfriends.input.ts -> `create-friends`
|
|
765
787
|
- check 'TODO FIXME'
|
|
766
788
|
- 22.12 node require esm (update all deps to latest)
|
|
789
|
+
|
|
790
|
+
## License
|
|
791
|
+
|
|
792
|
+
[MIT License](https://opensource.org/licenses/MIT) (c) 2025
|
package/generate.cjs
CHANGED
|
@@ -356,6 +356,9 @@ async function generateFiles(args) {
|
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
|
+
for (const customImport of config.customImport) {
|
|
360
|
+
imports.create(customImport);
|
|
361
|
+
}
|
|
359
362
|
sourceFile.set({
|
|
360
363
|
kind: tsMorph.StructureKind.SourceFile,
|
|
361
364
|
statements: [...imports.toStatements(), ...enums, ...classes]
|
|
@@ -1758,6 +1761,24 @@ function createConfig(data) {
|
|
|
1758
1761
|
arguments: element.arguments ? JSON5.parse(element.arguments) : undefined
|
|
1759
1762
|
});
|
|
1760
1763
|
}
|
|
1764
|
+
const customImport = [];
|
|
1765
|
+
const configCustomImport = Object.values(
|
|
1766
|
+
config.customImport || {}
|
|
1767
|
+
);
|
|
1768
|
+
for (const element of configCustomImport) {
|
|
1769
|
+
if (!element) continue;
|
|
1770
|
+
assert.ok(
|
|
1771
|
+
element.from && element.name,
|
|
1772
|
+
`Missed 'from' or 'name' part in configuration for customImport`
|
|
1773
|
+
);
|
|
1774
|
+
customImport.push({
|
|
1775
|
+
from: element.from,
|
|
1776
|
+
name: element.name,
|
|
1777
|
+
namedImport: toBoolean(element.namedImport),
|
|
1778
|
+
defaultImport: toBoolean(element.defaultImport) ? true : element.defaultImport,
|
|
1779
|
+
namespaceImport: element.namespaceImport
|
|
1780
|
+
});
|
|
1781
|
+
}
|
|
1761
1782
|
return {
|
|
1762
1783
|
outputFilePattern,
|
|
1763
1784
|
tsConfigFilePath: createTsConfigFilePathValue(config.tsConfigFilePath),
|
|
@@ -1781,7 +1802,8 @@ function createConfig(data) {
|
|
|
1781
1802
|
config.unsafeCompatibleWhereUniqueInput
|
|
1782
1803
|
),
|
|
1783
1804
|
graphqlScalars: config.graphqlScalars || {},
|
|
1784
|
-
decorate
|
|
1805
|
+
decorate,
|
|
1806
|
+
customImport
|
|
1785
1807
|
};
|
|
1786
1808
|
}
|
|
1787
1809
|
const tsConfigFileExists = lodash.memoize((filePath) => {
|
package/generate.d.ts
CHANGED
|
@@ -385,6 +385,13 @@ type DecorateElement = {
|
|
|
385
385
|
defaultImport?: string | true;
|
|
386
386
|
namespaceImport?: string;
|
|
387
387
|
};
|
|
388
|
+
type CustomImport = {
|
|
389
|
+
from: string;
|
|
390
|
+
name: string;
|
|
391
|
+
namedImport: boolean;
|
|
392
|
+
defaultImport?: string | true;
|
|
393
|
+
namespaceImport?: string;
|
|
394
|
+
};
|
|
388
395
|
declare function createConfig(data: Record<string, unknown>): {
|
|
389
396
|
outputFilePattern: string;
|
|
390
397
|
tsConfigFilePath: string | undefined;
|
|
@@ -405,6 +412,7 @@ declare function createConfig(data: Record<string, unknown>): {
|
|
|
405
412
|
unsafeCompatibleWhereUniqueInput: boolean;
|
|
406
413
|
graphqlScalars: Record<string, ImportNameSpec | undefined>;
|
|
407
414
|
decorate: DecorateElement[];
|
|
415
|
+
customImport: CustomImport[];
|
|
408
416
|
};
|
|
409
417
|
type ConfigInputItem = {
|
|
410
418
|
typeName: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prisma-nestjs-graphql",
|
|
3
|
-
"version": "21.
|
|
3
|
+
"version": "21.1.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
|
"bin": "bin.js",
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
"ts-morph": "11 - 16"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
+
"@apollo/server": "^4.11.3",
|
|
82
83
|
"@eslint/compat": "^1.2.5",
|
|
83
84
|
"@nestjs/apollo": "^13.0.1",
|
|
84
85
|
"@nestjs/common": "^11.0.1",
|
|
@@ -127,6 +128,7 @@
|
|
|
127
128
|
"graphql-scalars": "^1.24.0",
|
|
128
129
|
"graphql-type-json": "^0.3.2",
|
|
129
130
|
"mocha": "^11.0.1",
|
|
131
|
+
"node-dev": "^8.0.0",
|
|
130
132
|
"ololog": "^1.1.175",
|
|
131
133
|
"pkgroll": "^2.6.1",
|
|
132
134
|
"precise-commits": "^1.0.2",
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|