@k0lyan/typegraphql-prisma-nestjs 0.28.20
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/LICENSE +21 -0
- package/Readme.md +137 -0
- package/package.json +109 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019-2023 Michał Lytek
|
|
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.
|
package/Readme.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Fork of [typegraphql-prisma](https://www.npmjs.com/package/typegraphql-prisma)
|
|
2
|
+
|
|
3
|
+
This project is a fork of another with minor changes, created for personal use.
|
|
4
|
+
|
|
5
|
+
Long term support is not guaranteed, use of this copy is at your own risk.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npm install typegraphql-prisma-nestjs --save-dev
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Differences from the original project:
|
|
14
|
+
|
|
15
|
+
### Functions and classes used in generated files from scheme of [prisma](https://github.com/prisma/prisma), imports from [nestjs](https://nestjs.com)
|
|
16
|
+
|
|
17
|
+
Original:
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { Ctx, Query, Resolver } from "type-graphql";
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
In fork:
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { Context, Query, Resolver } from "@nestjs/graphql";
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Append transformArgsIntoPrismaArgs and setTransformArgsIntoPrismaArgs for modify args before send it to prisma
|
|
30
|
+
|
|
31
|
+
PR: https://github.com/MichalLytek/typegraphql-prisma/pull/399
|
|
32
|
+
|
|
33
|
+
Sample fork with this integrations: https://github.com/EndyKaufman/typegraphql-prisma-nestjs/commit/f80d055a9aad227502d023c673ba9eed28d5cc9b
|
|
34
|
+
|
|
35
|
+
Sample application with this feature: https://github.com/EndyKaufman/typegraphql-prisma-nestjs-example/commit/c43118e952bee58e2620f159fcc62c2595a9189b
|
|
36
|
+
|
|
37
|
+

|
|
38
|
+
|
|
39
|
+
### Add support mark part of fields as optional
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
@TypeGraphQL.optional(input: ["create", "update"])
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Add support call some async events after request to Prisma
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
setTransformArgsIntoPrismaArgs(async function <
|
|
49
|
+
TArgs = Record<string, any>,
|
|
50
|
+
TContext = any,
|
|
51
|
+
>(
|
|
52
|
+
info: GraphQLResolveInfo,
|
|
53
|
+
args: TArgs,
|
|
54
|
+
ctx: TContext,
|
|
55
|
+
modelName?: string,
|
|
56
|
+
collectionName?: string,
|
|
57
|
+
prismaMethod?: string,
|
|
58
|
+
afterProcessEvents?: ((result: any) => Promise<any>)[],
|
|
59
|
+
): Promise<TArgs> {
|
|
60
|
+
// ...some logic before request to prisma
|
|
61
|
+
afterProcessEvents?.push(async function (result) {
|
|
62
|
+
// ...some logic after request to prisma, variable result store output data
|
|
63
|
+
});
|
|
64
|
+
return args;
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Add options for skip generate methods and fields resolvers
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
emitActions: 'findUnique, findUniqueOrThrow, findFirst, findFirstOrThrow, findMany, createOne, createMany, createManyAndReturn, updateOne, updateMany, deleteOne, deleteMany, upsertOne, aggregate, groupBy'
|
|
72
|
+
|
|
73
|
+
emitPropertyMethods: 'create, connectOrCreate, upsert, set, disconnect, delete, connect, update, updateMany, deleteMany'
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Add option to enable using Dataloader when retrieving nested objects
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
useDataloaderForResolveFields: 'true' // use dataloader for entities
|
|
80
|
+
useDataloaderForAllResolveFields: 'true' // use dataloader for array of entities
|
|
81
|
+
useDataloaderMaxBatchSize: undefined // default `Infinity`. Limits the number of items that get passed in to the `batchLoadFn`. May be set to `1` to disable batching.
|
|
82
|
+
useDataloaderBatchScheduleFnDelay: 100 // the delay is needed to solve the problem with nextTick (https://github.com/graphql/dataloader/issues/285#issuecomment-2613792744), if the number of parallel requests is very large, then you need to increase this delay
|
|
83
|
+
useDataloaderCache: false // caching value with equal keys
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Example use NestJS + Prisma2 + Typegraphql
|
|
87
|
+
|
|
88
|
+
https://github.com/EndyKaufman/typegraphql-prisma-nestjs-example
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+

|
|
93
|
+
|
|
94
|
+
[](https://discord.gg/cWnBAQcbg2)
|
|
95
|
+
[](https://www.npmjs.com/package/typegraphql-prisma)
|
|
96
|
+
|
|
97
|
+
# TypeGraphQL & Prisma integration
|
|
98
|
+
|
|
99
|
+
Prisma generator to emit TypeGraphQL types and CRUD resolvers from your Prisma schema.
|
|
100
|
+
|
|
101
|
+
[**https://prisma.typegraphql.com**](https://prisma.typegraphql.com)
|
|
102
|
+
|
|
103
|
+
## Documentation
|
|
104
|
+
|
|
105
|
+
The documentation, installation guide, detailed description of the API and all of its features is [available on the website](https://prisma.typegraphql.com).
|
|
106
|
+
|
|
107
|
+
## Examples
|
|
108
|
+
|
|
109
|
+
You can check out some usage examples on this repo:
|
|
110
|
+
|
|
111
|
+
https://github.com/EndyKaufman/typegraphql-prisma-nestjs-example
|
|
112
|
+
|
|
113
|
+
## Feedback
|
|
114
|
+
|
|
115
|
+
Currently released version `0.x` is just a preview of the upcoming integration. For now it lacks some customization option - picking models or fields of object types to expose in the schema, hiding input fields as well as picking exposed args fields. However, the base functionality is working well, so I strongly encourage you to give it a try and play with it.
|
|
116
|
+
|
|
117
|
+
Any feedback about the developers experience or ideas about new features or enhancements are very welcome - please feel free to put your two cents by using the [GitHub Discussions feature](https://github.com/MichalLytek/typegraphql-prisma/discussions/new):
|
|
118
|
+
|
|
119
|
+
<img src="https://raw.githubusercontent.com/MichalLytek/typegraphql-prisma/main/img/feedback.png" width="327"/>
|
|
120
|
+
|
|
121
|
+
## Security contact information
|
|
122
|
+
|
|
123
|
+
To report a security vulnerability, please use the
|
|
124
|
+
[Tidelift security contact](https://tidelift.com/security).
|
|
125
|
+
Tidelift will coordinate the fix and disclosure.
|
|
126
|
+
|
|
127
|
+
## Future of this project
|
|
128
|
+
|
|
129
|
+
This project is not sponsored by Prisma anymore, so there will be provided only bug fixes and Prisma compatibility upgrades.
|
|
130
|
+
You can read more about this in the GitHub issue [#385](https://github.com/MichalLytek/typegraphql-prisma/issues/385).
|
|
131
|
+
|
|
132
|
+
Let's keep `typegraphql-prisma` alive together! 💪
|
|
133
|
+
|
|
134
|
+
## Community
|
|
135
|
+
|
|
136
|
+
- Visit the [Official Website](https://prisma.typegraphql.com)
|
|
137
|
+
- Chat on [Discord](https://discord.gg/cWnBAQcbg2)
|
package/package.json
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@k0lyan/typegraphql-prisma-nestjs",
|
|
3
|
+
"version": "0.28.20",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"build": "tsc",
|
|
6
|
+
"package:build": "./package.sh",
|
|
7
|
+
"package:publish": "cd package *&& npm publish",
|
|
8
|
+
"check:type": "tsc --noEmit --skipLibCheck",
|
|
9
|
+
"check:experiments:postgres": "cd ./experiments/postgres && tsc --noEmit --skipLibCheck",
|
|
10
|
+
"check:experiments:mongodb": "cd ./experiments/mongodb && tsc --noEmit --skipLibCheck",
|
|
11
|
+
"check:format": "prettier --ignore-path ./.cli.prettierignore --check ./**/*.{js,json,ts,tsx}",
|
|
12
|
+
"test": "ts-node ./tests/helpers/setup-tests.ts && jest --watch --verbose",
|
|
13
|
+
"test:integration": "ts-node ./tests/helpers/setup-tests.ts && env-cmd jest --watch --verbose --config ./jest.config.integration.ts",
|
|
14
|
+
"test:ci": "ts-node ./tests/helpers/setup-tests.ts && jest --coverage --verbose --runInBand && jest --coverage --verbose --runInBand --config ./jest.config.integration.ts",
|
|
15
|
+
"format": "prettier --ignore-path ./.cli.prettierignore --write ./**/*.{js,json,ts,tsx}"
|
|
16
|
+
},
|
|
17
|
+
"bin": {
|
|
18
|
+
"typegraphql-prisma-nestjs": "lib/generator.js"
|
|
19
|
+
},
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"@prisma/client": "*",
|
|
22
|
+
"@types/graphql-fields": "*",
|
|
23
|
+
"@types/node": "*",
|
|
24
|
+
"graphql-fields": "*",
|
|
25
|
+
"graphql-scalars": "*",
|
|
26
|
+
"prisma": "*",
|
|
27
|
+
"tslib": "*"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@antfu/ni": "0.22.0",
|
|
31
|
+
"@opentelemetry/api": "1.9.0",
|
|
32
|
+
"@prisma/generator-helper": "^6.10.1",
|
|
33
|
+
"@prisma/internals": "^6.10.1",
|
|
34
|
+
"dotenv": "16.4.5",
|
|
35
|
+
"fp-ts": "2.16.9",
|
|
36
|
+
"fs-jetpack": "5.1.0",
|
|
37
|
+
"http-proxy-agent": "7.0.2",
|
|
38
|
+
"https-proxy-agent": "7.0.5",
|
|
39
|
+
"pluralize": "^8.0.0",
|
|
40
|
+
"semver": "^7.6.3",
|
|
41
|
+
"ts-morph": "^23.0.0",
|
|
42
|
+
"tslib": "*"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@jest/types": "^29.6.3",
|
|
46
|
+
"@prisma/client": "^5.18.0",
|
|
47
|
+
"@types/graphql-fields": "^1.3.9",
|
|
48
|
+
"@types/jest": "^29.5.12",
|
|
49
|
+
"@types/node": "^22.1.0",
|
|
50
|
+
"@types/pg": "^8.11.6",
|
|
51
|
+
"@types/pluralize": "0.0.33",
|
|
52
|
+
"@types/semver": "^7.5.8",
|
|
53
|
+
"@types/validator": "^13.12.0",
|
|
54
|
+
"@types/yargs-parser": "^21.0.3",
|
|
55
|
+
"directory-tree": "^3.5.2",
|
|
56
|
+
"env-cmd": "^10.1.0",
|
|
57
|
+
"graphql": "^16.9.0",
|
|
58
|
+
"graphql-fields": "^2.0.3",
|
|
59
|
+
"graphql-scalars": "^1.23.0",
|
|
60
|
+
"husky": "^8.0.3",
|
|
61
|
+
"jest": "^29.7.0",
|
|
62
|
+
"lint-staged": "^15.2.8",
|
|
63
|
+
"pg": "^8.12.0",
|
|
64
|
+
"prettier": "^3.3.3",
|
|
65
|
+
"prettier-2": "npm:prettier@^2",
|
|
66
|
+
"prisma": "^5.18.0",
|
|
67
|
+
"reflect-metadata": "0.1.13",
|
|
68
|
+
"ts-jest": "~29.2.4",
|
|
69
|
+
"ts-node": "^10.9.2",
|
|
70
|
+
"ts-toolbelt": "^9.6.0",
|
|
71
|
+
"tslib": "^2.6.3",
|
|
72
|
+
"type-graphql": "2.0.0-rc.2",
|
|
73
|
+
"typescript": "~5.5.4"
|
|
74
|
+
},
|
|
75
|
+
"license": "MIT",
|
|
76
|
+
"engines": {
|
|
77
|
+
"node": ">=20.11.1"
|
|
78
|
+
},
|
|
79
|
+
"author": {
|
|
80
|
+
"name": "Michał Lytek",
|
|
81
|
+
"url": "https://github.com/MichalLytek"
|
|
82
|
+
},
|
|
83
|
+
"repository": {
|
|
84
|
+
"type": "git",
|
|
85
|
+
"url": "https://github.com/EndyKaufman/typegraphql-prisma-nestjs.git"
|
|
86
|
+
},
|
|
87
|
+
"bugs": {
|
|
88
|
+
"url": "https://github.com/EndyKaufman/typegraphql-prisma-nestjs/issues"
|
|
89
|
+
},
|
|
90
|
+
"keywords": [
|
|
91
|
+
"nestjs",
|
|
92
|
+
"type-graphql",
|
|
93
|
+
"typegraphql",
|
|
94
|
+
"prisma",
|
|
95
|
+
"prisma2",
|
|
96
|
+
"prisma-framework",
|
|
97
|
+
"graphql",
|
|
98
|
+
"generator"
|
|
99
|
+
],
|
|
100
|
+
"lint-staged": {
|
|
101
|
+
"**/*.{ts,tsx}": [
|
|
102
|
+
"prettier --write"
|
|
103
|
+
],
|
|
104
|
+
"**/*.{js,json}": [
|
|
105
|
+
"prettier --write"
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
"private": false
|
|
109
|
+
}
|