@k0lyan/nestjs-prisma-graphql-generator 0.1.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/LICENSE +21 -0
- package/README.md +210 -0
- package/dist/cli/generator.d.ts +3 -0
- package/dist/cli/generator.d.ts.map +1 -0
- package/dist/cli/generator.js +24 -0
- package/dist/cli/generator.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +18 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/options-parser.d.ts +48 -0
- package/dist/cli/options-parser.d.ts.map +1 -0
- package/dist/cli/options-parser.js +61 -0
- package/dist/cli/options-parser.js.map +1 -0
- package/dist/cli/prisma-generator.d.ts +4 -0
- package/dist/cli/prisma-generator.d.ts.map +1 -0
- package/dist/cli/prisma-generator.js +27 -0
- package/dist/cli/prisma-generator.js.map +1 -0
- package/dist/generator/common.d.ts +7 -0
- package/dist/generator/common.d.ts.map +1 -0
- package/dist/generator/common.js +87 -0
- package/dist/generator/common.js.map +1 -0
- package/dist/generator/dmmf/document.d.ts +96 -0
- package/dist/generator/dmmf/document.d.ts.map +1 -0
- package/dist/generator/dmmf/document.js +223 -0
- package/dist/generator/dmmf/document.js.map +1 -0
- package/dist/generator/dmmf/index.d.ts +4 -0
- package/dist/generator/dmmf/index.d.ts.map +1 -0
- package/dist/generator/dmmf/index.js +20 -0
- package/dist/generator/dmmf/index.js.map +1 -0
- package/dist/generator/dmmf/transformer.d.ts +59 -0
- package/dist/generator/dmmf/transformer.d.ts.map +1 -0
- package/dist/generator/dmmf/transformer.js +247 -0
- package/dist/generator/dmmf/transformer.js.map +1 -0
- package/dist/generator/dmmf/types.d.ts +169 -0
- package/dist/generator/dmmf/types.d.ts.map +1 -0
- package/dist/generator/dmmf/types.js +32 -0
- package/dist/generator/dmmf/types.js.map +1 -0
- package/dist/generator/generate.d.ts +10 -0
- package/dist/generator/generate.d.ts.map +1 -0
- package/dist/generator/generate.js +131 -0
- package/dist/generator/generate.js.map +1 -0
- package/dist/generator/helpers-generator.d.ts +7 -0
- package/dist/generator/helpers-generator.d.ts.map +1 -0
- package/dist/generator/helpers-generator.js +216 -0
- package/dist/generator/helpers-generator.js.map +1 -0
- package/dist/generator/index.d.ts +7 -0
- package/dist/generator/index.d.ts.map +1 -0
- package/dist/generator/index.js +23 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/generator/templates/args.d.ts +8 -0
- package/dist/generator/templates/args.d.ts.map +1 -0
- package/dist/generator/templates/args.js +650 -0
- package/dist/generator/templates/args.js.map +1 -0
- package/dist/generator/templates/enum.d.ts +8 -0
- package/dist/generator/templates/enum.d.ts.map +1 -0
- package/dist/generator/templates/enum.js +66 -0
- package/dist/generator/templates/enum.js.map +1 -0
- package/dist/generator/templates/index.d.ts +6 -0
- package/dist/generator/templates/index.d.ts.map +1 -0
- package/dist/generator/templates/index.js +22 -0
- package/dist/generator/templates/index.js.map +1 -0
- package/dist/generator/templates/input.d.ts +8 -0
- package/dist/generator/templates/input.d.ts.map +1 -0
- package/dist/generator/templates/input.js +248 -0
- package/dist/generator/templates/input.js.map +1 -0
- package/dist/generator/templates/model.d.ts +8 -0
- package/dist/generator/templates/model.d.ts.map +1 -0
- package/dist/generator/templates/model.js +184 -0
- package/dist/generator/templates/model.js.map +1 -0
- package/dist/generator/templates/resolver.d.ts +8 -0
- package/dist/generator/templates/resolver.d.ts.map +1 -0
- package/dist/generator/templates/resolver.js +456 -0
- package/dist/generator/templates/resolver.js.map +1 -0
- package/dist/generator/writers/file-writer.d.ts +10 -0
- package/dist/generator/writers/file-writer.d.ts.map +1 -0
- package/dist/generator/writers/file-writer.js +40 -0
- package/dist/generator/writers/file-writer.js.map +1 -0
- package/dist/generator/writers/index.d.ts +2 -0
- package/dist/generator/writers/index.d.ts.map +1 -0
- package/dist/generator/writers/index.js +18 -0
- package/dist/generator/writers/index.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime/helpers.d.ts +102 -0
- package/dist/runtime/helpers.d.ts.map +1 -0
- package/dist/runtime/helpers.js +210 -0
- package/dist/runtime/helpers.js.map +1 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +18 -0
- package/dist/runtime/index.js.map +1 -0
- package/package.json +79 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime helpers for NestJS Prisma GraphQL Generator
|
|
3
|
+
*
|
|
4
|
+
* These helpers are used at runtime to transform GraphQL queries
|
|
5
|
+
* into optimized Prisma select/include objects.
|
|
6
|
+
*/
|
|
7
|
+
import { ResolveTree } from 'graphql-parse-resolve-info';
|
|
8
|
+
import type { GraphQLResolveInfo } from 'graphql';
|
|
9
|
+
/**
|
|
10
|
+
* Prisma select/include object type
|
|
11
|
+
*/
|
|
12
|
+
export interface PrismaSelect {
|
|
13
|
+
select?: Record<string, boolean | PrismaSelect>;
|
|
14
|
+
include?: Record<string, boolean | PrismaSelect>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Context type that should contain the Prisma client
|
|
18
|
+
*/
|
|
19
|
+
export interface GraphQLContext {
|
|
20
|
+
prisma: any;
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Transform GraphQL resolve info into Prisma select/include arguments
|
|
25
|
+
*
|
|
26
|
+
* This is the core optimization function that analyzes the GraphQL query
|
|
27
|
+
* and builds an optimal Prisma query with only the requested fields.
|
|
28
|
+
*
|
|
29
|
+
* @param info - GraphQL resolve info from the resolver
|
|
30
|
+
* @returns Prisma select object
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* @Query(() => [User])
|
|
35
|
+
* async users(@Info() info: GraphQLResolveInfo) {
|
|
36
|
+
* const select = transformInfoIntoPrismaArgs(info);
|
|
37
|
+
* return prisma.user.findMany({
|
|
38
|
+
* ...select,
|
|
39
|
+
* });
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function transformInfoIntoPrismaArgs(info: GraphQLResolveInfo): PrismaSelect;
|
|
44
|
+
/**
|
|
45
|
+
* Get Prisma client from GraphQL context
|
|
46
|
+
*
|
|
47
|
+
* @param info - GraphQL resolve info
|
|
48
|
+
* @returns Prisma client instance
|
|
49
|
+
* @throws Error if Prisma client is not found in context
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const prisma = getPrismaFromContext(info);
|
|
54
|
+
* return prisma.user.findMany();
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function getPrismaFromContext(info: GraphQLResolveInfo): any;
|
|
58
|
+
/**
|
|
59
|
+
* Transform count fields into Prisma _count select
|
|
60
|
+
*
|
|
61
|
+
* Handles the special _count field that aggregates relation counts
|
|
62
|
+
*
|
|
63
|
+
* @param fields - Parsed fields containing _count
|
|
64
|
+
* @returns Prisma _count select object
|
|
65
|
+
*/
|
|
66
|
+
export declare function transformCountFieldIntoSelectRelationsCount(fields: Record<string, ResolveTree>): {
|
|
67
|
+
_count?: {
|
|
68
|
+
select: Record<string, boolean>;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Merge multiple Prisma select objects
|
|
73
|
+
*
|
|
74
|
+
* @param selects - Array of PrismaSelect objects to merge
|
|
75
|
+
* @returns Merged PrismaSelect object
|
|
76
|
+
*/
|
|
77
|
+
export declare function mergePrismaSelects(...selects: PrismaSelect[]): PrismaSelect;
|
|
78
|
+
/**
|
|
79
|
+
* Check if a field is a relation based on Prisma schema info
|
|
80
|
+
*
|
|
81
|
+
* This is a simple heuristic - in generated code, we have full schema info
|
|
82
|
+
*
|
|
83
|
+
* @param fieldName - Name of the field
|
|
84
|
+
* @param modelFields - Map of field names to their types
|
|
85
|
+
* @returns true if the field is a relation
|
|
86
|
+
*/
|
|
87
|
+
export declare function isRelationField(fieldName: string, modelFields: Map<string, {
|
|
88
|
+
isRelation: boolean;
|
|
89
|
+
}>): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Apply pagination to Prisma args
|
|
92
|
+
*
|
|
93
|
+
* @param args - Existing Prisma args
|
|
94
|
+
* @param pagination - Pagination options
|
|
95
|
+
* @returns Prisma args with pagination
|
|
96
|
+
*/
|
|
97
|
+
export declare function applyPagination<T extends object>(args: T, pagination?: {
|
|
98
|
+
skip?: number;
|
|
99
|
+
take?: number;
|
|
100
|
+
cursor?: any;
|
|
101
|
+
}): T;
|
|
102
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/runtime/helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,WAAW,EAGZ,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,YAAY,CAAC,CAAC;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,YAAY,CAAC,CAAC;CAClD;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,GAAG,CAAC;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAQD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,kBAAkB,GAAG,YAAY,CAalF;AAmDD;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,kBAAkB,GAAG,GAAG,CAoBlE;AAED;;;;;;;GAOG;AACH,wBAAgB,2CAA2C,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG;IAChG,MAAM,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;CAC9C,CAkCA;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,OAAO,EAAE,YAAY,EAAE,GAAG,YAAY,CAmB3E;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE;IAAE,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC,GAChD,OAAO,CAGT;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,EAC9C,IAAI,EAAE,CAAC,EACP,UAAU,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,GAAG,CAAA;CAAE,GAC1D,CAAC,CAWH"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Runtime helpers for NestJS Prisma GraphQL Generator
|
|
4
|
+
*
|
|
5
|
+
* These helpers are used at runtime to transform GraphQL queries
|
|
6
|
+
* into optimized Prisma select/include objects.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.transformInfoIntoPrismaArgs = transformInfoIntoPrismaArgs;
|
|
10
|
+
exports.getPrismaFromContext = getPrismaFromContext;
|
|
11
|
+
exports.transformCountFieldIntoSelectRelationsCount = transformCountFieldIntoSelectRelationsCount;
|
|
12
|
+
exports.mergePrismaSelects = mergePrismaSelects;
|
|
13
|
+
exports.isRelationField = isRelationField;
|
|
14
|
+
exports.applyPagination = applyPagination;
|
|
15
|
+
const graphql_parse_resolve_info_1 = require("graphql-parse-resolve-info");
|
|
16
|
+
/**
|
|
17
|
+
* Fields that should be excluded from selection
|
|
18
|
+
* These are GraphQL internal fields or aggregation fields
|
|
19
|
+
*/
|
|
20
|
+
const EXCLUDED_FIELDS = new Set(['__typename', '_count', '_avg', '_sum', '_min', '_max']);
|
|
21
|
+
/**
|
|
22
|
+
* Transform GraphQL resolve info into Prisma select/include arguments
|
|
23
|
+
*
|
|
24
|
+
* This is the core optimization function that analyzes the GraphQL query
|
|
25
|
+
* and builds an optimal Prisma query with only the requested fields.
|
|
26
|
+
*
|
|
27
|
+
* @param info - GraphQL resolve info from the resolver
|
|
28
|
+
* @returns Prisma select object
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* @Query(() => [User])
|
|
33
|
+
* async users(@Info() info: GraphQLResolveInfo) {
|
|
34
|
+
* const select = transformInfoIntoPrismaArgs(info);
|
|
35
|
+
* return prisma.user.findMany({
|
|
36
|
+
* ...select,
|
|
37
|
+
* });
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
function transformInfoIntoPrismaArgs(info) {
|
|
42
|
+
const parsedInfo = (0, graphql_parse_resolve_info_1.parseResolveInfo)(info);
|
|
43
|
+
if (!parsedInfo) {
|
|
44
|
+
return {};
|
|
45
|
+
}
|
|
46
|
+
const simplifiedInfo = (0, graphql_parse_resolve_info_1.simplifyParsedResolveInfoFragmentWithType)(parsedInfo, info.returnType);
|
|
47
|
+
return buildPrismaSelect(simplifiedInfo.fields);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Build Prisma select object from parsed GraphQL fields
|
|
51
|
+
*
|
|
52
|
+
* @param fields - Parsed fields from graphql-parse-resolve-info
|
|
53
|
+
* @returns Prisma select object
|
|
54
|
+
*/
|
|
55
|
+
function buildPrismaSelect(fields) {
|
|
56
|
+
const select = {};
|
|
57
|
+
for (const [fieldName, fieldInfo] of Object.entries(fields)) {
|
|
58
|
+
// Skip excluded fields
|
|
59
|
+
if (EXCLUDED_FIELDS.has(fieldName)) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
// Check if field has nested selections (relation)
|
|
63
|
+
const nestedFields = fieldInfo.fieldsByTypeName;
|
|
64
|
+
const nestedTypes = Object.keys(nestedFields);
|
|
65
|
+
if (nestedTypes.length > 0) {
|
|
66
|
+
// This is a relation field - need to use include or nested select
|
|
67
|
+
// Merge fields from all possible types (for union/interface types)
|
|
68
|
+
const allNestedFields = {};
|
|
69
|
+
for (const typeName of nestedTypes) {
|
|
70
|
+
Object.assign(allNestedFields, nestedFields[typeName]);
|
|
71
|
+
}
|
|
72
|
+
// Recursively build select for nested fields
|
|
73
|
+
const nestedSelect = buildPrismaSelect(allNestedFields);
|
|
74
|
+
if (Object.keys(nestedSelect).length > 0) {
|
|
75
|
+
select[fieldName] = nestedSelect;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
select[fieldName] = true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
// Scalar field
|
|
83
|
+
select[fieldName] = true;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (Object.keys(select).length === 0) {
|
|
87
|
+
return {};
|
|
88
|
+
}
|
|
89
|
+
return { select };
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Get Prisma client from GraphQL context
|
|
93
|
+
*
|
|
94
|
+
* @param info - GraphQL resolve info
|
|
95
|
+
* @returns Prisma client instance
|
|
96
|
+
* @throws Error if Prisma client is not found in context
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* const prisma = getPrismaFromContext(info);
|
|
101
|
+
* return prisma.user.findMany();
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
function getPrismaFromContext(info) {
|
|
105
|
+
const context = info.variableValues?.context ||
|
|
106
|
+
info.rootValue?.context ||
|
|
107
|
+
info.context;
|
|
108
|
+
if (context?.prisma) {
|
|
109
|
+
return context.prisma;
|
|
110
|
+
}
|
|
111
|
+
// Fallback: try to get from rootValue directly
|
|
112
|
+
const rootValue = info.rootValue;
|
|
113
|
+
if (rootValue?.prisma) {
|
|
114
|
+
return rootValue.prisma;
|
|
115
|
+
}
|
|
116
|
+
throw new Error('Prisma client not found in GraphQL context. ' +
|
|
117
|
+
'Make sure to pass the Prisma client in the context: { prisma }');
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Transform count fields into Prisma _count select
|
|
121
|
+
*
|
|
122
|
+
* Handles the special _count field that aggregates relation counts
|
|
123
|
+
*
|
|
124
|
+
* @param fields - Parsed fields containing _count
|
|
125
|
+
* @returns Prisma _count select object
|
|
126
|
+
*/
|
|
127
|
+
function transformCountFieldIntoSelectRelationsCount(fields) {
|
|
128
|
+
const countField = fields['_count'];
|
|
129
|
+
if (!countField) {
|
|
130
|
+
return {};
|
|
131
|
+
}
|
|
132
|
+
const countNestedFields = countField.fieldsByTypeName;
|
|
133
|
+
const countTypes = Object.keys(countNestedFields);
|
|
134
|
+
if (countTypes.length === 0) {
|
|
135
|
+
return {};
|
|
136
|
+
}
|
|
137
|
+
const countSelect = {};
|
|
138
|
+
for (const typeName of countTypes) {
|
|
139
|
+
const typeFields = countNestedFields[typeName];
|
|
140
|
+
if (typeFields) {
|
|
141
|
+
for (const fieldName of Object.keys(typeFields)) {
|
|
142
|
+
countSelect[fieldName] = true;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (Object.keys(countSelect).length === 0) {
|
|
147
|
+
return {};
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
_count: {
|
|
151
|
+
select: countSelect,
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Merge multiple Prisma select objects
|
|
157
|
+
*
|
|
158
|
+
* @param selects - Array of PrismaSelect objects to merge
|
|
159
|
+
* @returns Merged PrismaSelect object
|
|
160
|
+
*/
|
|
161
|
+
function mergePrismaSelects(...selects) {
|
|
162
|
+
const result = {};
|
|
163
|
+
for (const select of selects) {
|
|
164
|
+
if (select.select) {
|
|
165
|
+
result.select = {
|
|
166
|
+
...result.select,
|
|
167
|
+
...select.select,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
if (select.include) {
|
|
171
|
+
result.include = {
|
|
172
|
+
...result.include,
|
|
173
|
+
...select.include,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return result;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Check if a field is a relation based on Prisma schema info
|
|
181
|
+
*
|
|
182
|
+
* This is a simple heuristic - in generated code, we have full schema info
|
|
183
|
+
*
|
|
184
|
+
* @param fieldName - Name of the field
|
|
185
|
+
* @param modelFields - Map of field names to their types
|
|
186
|
+
* @returns true if the field is a relation
|
|
187
|
+
*/
|
|
188
|
+
function isRelationField(fieldName, modelFields) {
|
|
189
|
+
const field = modelFields.get(fieldName);
|
|
190
|
+
return field?.isRelation ?? false;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Apply pagination to Prisma args
|
|
194
|
+
*
|
|
195
|
+
* @param args - Existing Prisma args
|
|
196
|
+
* @param pagination - Pagination options
|
|
197
|
+
* @returns Prisma args with pagination
|
|
198
|
+
*/
|
|
199
|
+
function applyPagination(args, pagination) {
|
|
200
|
+
if (!pagination) {
|
|
201
|
+
return args;
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
...args,
|
|
205
|
+
...(pagination.skip !== undefined && { skip: pagination.skip }),
|
|
206
|
+
...(pagination.take !== undefined && { take: pagination.take }),
|
|
207
|
+
...(pagination.cursor !== undefined && { cursor: pagination.cursor }),
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
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AAM,CAAC,OAAO,EAAE,CAAC;YACnB,MAAM,CAAC,OAAO,GAAG;gBACf,GAAG,MAAM,CAAC,OAAO;gBACjB,GAAG,MAAM,CAAC,OAAO;aAClB,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,eAAe,CAC7B,SAAiB,EACjB,WAAiD;IAEjD,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACzC,OAAO,KAAK,EAAE,UAAU,IAAI,KAAK,CAAC;AACpC,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,eAAe,CAC7B,IAAO,EACP,UAA2D;IAE3D,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,GAAG,IAAI;QACP,GAAG,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC;QAC/D,GAAG,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC;QAC/D,GAAG,CAAC,UAAU,CAAC,MAAM,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC;KACtE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./helpers"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B"}
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@k0lyan/nestjs-prisma-graphql-generator",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Prisma generator for NestJS 11 GraphQL with optimized query building from GraphQL selections",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"nestjs-prisma-graphql-generator": "dist/cli/generator.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"build:watch": "tsc --watch",
|
|
18
|
+
"clean": "rm -rf dist",
|
|
19
|
+
"prepublishOnly": "npm run clean && npm run build && npm test",
|
|
20
|
+
"test": "jest",
|
|
21
|
+
"test:watch": "jest --watch",
|
|
22
|
+
"test:coverage": "jest --coverage",
|
|
23
|
+
"lint": "eslint src --ext .ts",
|
|
24
|
+
"format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\""
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"prisma",
|
|
28
|
+
"prisma-generator",
|
|
29
|
+
"nestjs",
|
|
30
|
+
"graphql",
|
|
31
|
+
"typescript",
|
|
32
|
+
"code-generator",
|
|
33
|
+
"nestjs-graphql",
|
|
34
|
+
"prisma-nestjs",
|
|
35
|
+
"n+1",
|
|
36
|
+
"query-optimization"
|
|
37
|
+
],
|
|
38
|
+
"author": "",
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=18.0.0"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://github.com/k0lyan/nestjs-prisma-graphql-generator#readme",
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/k0lyan/nestjs-prisma-graphql-generator/issues"
|
|
46
|
+
},
|
|
47
|
+
"repository": {
|
|
48
|
+
"type": "git",
|
|
49
|
+
"url": "git+https://github.com/k0lyan/nestjs-prisma-graphql-generator.git"
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@prisma/generator-helper": "^7.0.0",
|
|
56
|
+
"@prisma/internals": "^7.0.0",
|
|
57
|
+
"graphql-parse-resolve-info": "^4.14.0",
|
|
58
|
+
"pluralize": "^8.0.0",
|
|
59
|
+
"ts-morph": "^27.0.0"
|
|
60
|
+
},
|
|
61
|
+
"peerDependencies": {
|
|
62
|
+
"@nestjs/common": ">=10.0.0",
|
|
63
|
+
"@nestjs/graphql": ">=12.0.0",
|
|
64
|
+
"@prisma/client": ">=7.0.0",
|
|
65
|
+
"graphql": "^16.0.0"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@types/jest": "^29.5.12",
|
|
69
|
+
"@types/node": "^20.11.0",
|
|
70
|
+
"@types/pluralize": "^0.0.33",
|
|
71
|
+
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
|
72
|
+
"@typescript-eslint/parser": "^7.0.0",
|
|
73
|
+
"eslint": "^8.57.0",
|
|
74
|
+
"jest": "^29.7.0",
|
|
75
|
+
"prettier": "^3.2.0",
|
|
76
|
+
"ts-jest": "^29.1.2",
|
|
77
|
+
"typescript": "^5.4.0"
|
|
78
|
+
}
|
|
79
|
+
}
|