@k0lyan/nestjs-prisma-graphql-generator 0.8.4 → 0.8.6
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.
|
@@ -73,6 +73,94 @@ export interface GraphQLContext<PrismaClient = unknown> {
|
|
|
73
73
|
[key: string]: unknown;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Prisma DMMF type for model field introspection
|
|
78
|
+
*/
|
|
79
|
+
export interface PrismaDMMF {
|
|
80
|
+
datamodel: {
|
|
81
|
+
models: Array<{
|
|
82
|
+
name: string;
|
|
83
|
+
fields: Array<{
|
|
84
|
+
name: string;
|
|
85
|
+
kind: string;
|
|
86
|
+
type: string;
|
|
87
|
+
}>;
|
|
88
|
+
}>;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Model field information extracted from DMMF
|
|
94
|
+
*/
|
|
95
|
+
export interface ModelFieldInfo {
|
|
96
|
+
/** Scalar field names (non-relation fields) */
|
|
97
|
+
scalars: Set<string>;
|
|
98
|
+
/** Relation field name -> related model name */
|
|
99
|
+
relations: Map<string, string>;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Cache for model fields extracted from DMMF
|
|
104
|
+
*/
|
|
105
|
+
const modelFieldsCache = new Map<string, ModelFieldInfo>();
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Extract scalar and relation field names from Prisma DMMF for a model.
|
|
109
|
+
* Results are cached for performance.
|
|
110
|
+
*/
|
|
111
|
+
export function getModelFields(dmmf: PrismaDMMF, modelName: string): ModelFieldInfo {
|
|
112
|
+
const cacheKey = modelName;
|
|
113
|
+
if (modelFieldsCache.has(cacheKey)) {
|
|
114
|
+
return modelFieldsCache.get(cacheKey)!;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const model = dmmf.datamodel.models.find((m) => m.name === modelName);
|
|
118
|
+
if (!model) {
|
|
119
|
+
throw new Error(\`Model "\${modelName}" not found in Prisma DMMF\`);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const scalars = new Set<string>();
|
|
123
|
+
const relations = new Map<string, string>();
|
|
124
|
+
|
|
125
|
+
for (const field of model.fields) {
|
|
126
|
+
if (field.kind === 'object') {
|
|
127
|
+
relations.set(field.name, field.type);
|
|
128
|
+
} else {
|
|
129
|
+
scalars.add(field.name);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const info: ModelFieldInfo = { scalars, relations };
|
|
134
|
+
modelFieldsCache.set(cacheKey, info);
|
|
135
|
+
return info;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Options for transformInfoIntoPrismaArgs
|
|
140
|
+
*/
|
|
141
|
+
export interface TransformOptions {
|
|
142
|
+
/**
|
|
143
|
+
* Fields to exclude from the Prisma select at all nesting levels.
|
|
144
|
+
* Use this for custom @ResolveField() computed fields that don't exist in Prisma.
|
|
145
|
+
* @example ['occupationStatus', 'computedField']
|
|
146
|
+
*/
|
|
147
|
+
excludeFields?: string[];
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Prisma DMMF for automatic field filtering.
|
|
151
|
+
* When provided with modelName, only valid Prisma fields will be selected.
|
|
152
|
+
* @example Prisma.dmmf
|
|
153
|
+
*/
|
|
154
|
+
dmmf?: PrismaDMMF;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Root model name for automatic field filtering.
|
|
158
|
+
* Used with dmmf to filter out non-Prisma fields recursively.
|
|
159
|
+
* @example 'User'
|
|
160
|
+
*/
|
|
161
|
+
modelName?: string;
|
|
162
|
+
}
|
|
163
|
+
|
|
76
164
|
/**
|
|
77
165
|
* Fields that should be excluded from selection
|
|
78
166
|
*/
|
|
@@ -162,10 +250,14 @@ function extractFieldArgs(
|
|
|
162
250
|
* Parse a selection set into a Prisma select object
|
|
163
251
|
* This function works directly with the AST without schema type introspection.
|
|
164
252
|
* It also extracts relation arguments (where, orderBy, take, skip, cursor, distinct).
|
|
253
|
+
* When dmmf and modelFields are provided, filters out fields not in Prisma model.
|
|
165
254
|
*/
|
|
166
255
|
function parseSelectionSetSimple(
|
|
167
256
|
selectionSet: SelectionSetNode | undefined,
|
|
168
257
|
info: GraphQLResolveInfo,
|
|
258
|
+
excludeFields?: Set<string>,
|
|
259
|
+
dmmf?: PrismaDMMF,
|
|
260
|
+
modelFields?: ModelFieldInfo,
|
|
169
261
|
): Record<string, boolean | PrismaRelation> {
|
|
170
262
|
const select: Record<string, boolean | PrismaRelation> = {};
|
|
171
263
|
|
|
@@ -181,15 +273,62 @@ function parseSelectionSetSimple(
|
|
|
181
273
|
const fieldNode = selection as FieldNode;
|
|
182
274
|
const fieldName = fieldNode.name.value;
|
|
183
275
|
|
|
184
|
-
// Skip excluded fields
|
|
185
|
-
if (EXCLUDED_FIELDS.has(fieldName)) {
|
|
276
|
+
// Skip excluded fields (internal + user-specified)
|
|
277
|
+
if (EXCLUDED_FIELDS.has(fieldName) || excludeFields?.has(fieldName)) {
|
|
186
278
|
continue;
|
|
187
279
|
}
|
|
188
280
|
|
|
189
|
-
//
|
|
281
|
+
// If modelFields provided, filter based on Prisma model schema
|
|
282
|
+
if (modelFields) {
|
|
283
|
+
const isScalar = modelFields.scalars.has(fieldName);
|
|
284
|
+
const isRelation = modelFields.relations.has(fieldName);
|
|
285
|
+
|
|
286
|
+
if (!isScalar && !isRelation) {
|
|
287
|
+
// Field doesn't exist in Prisma model - skip it (custom @ResolveField)
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
if (isRelation && fieldNode.selectionSet && dmmf) {
|
|
292
|
+
// For relations, recursively get related model's fields
|
|
293
|
+
const relatedModelName = modelFields.relations.get(fieldName)!;
|
|
294
|
+
const relatedModelFields = getModelFields(dmmf, relatedModelName);
|
|
295
|
+
const nestedSelect = parseSelectionSetSimple(
|
|
296
|
+
fieldNode.selectionSet,
|
|
297
|
+
info,
|
|
298
|
+
excludeFields,
|
|
299
|
+
dmmf,
|
|
300
|
+
relatedModelFields,
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
const relationArgs = extractFieldArgs(fieldNode, variableValues);
|
|
304
|
+
|
|
305
|
+
if (Object.keys(nestedSelect).length > 0) {
|
|
306
|
+
select[fieldName] = { select: nestedSelect, ...relationArgs };
|
|
307
|
+
} else {
|
|
308
|
+
select[fieldName] = Object.keys(relationArgs).length > 0
|
|
309
|
+
? { ...relationArgs }
|
|
310
|
+
: true;
|
|
311
|
+
}
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// Scalar field
|
|
316
|
+
if (isScalar) {
|
|
317
|
+
select[fieldName] = true;
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// Fallback: no modelFields filtering (original behavior)
|
|
190
323
|
if (fieldNode.selectionSet) {
|
|
191
324
|
// Recursively parse nested selections
|
|
192
|
-
const nestedSelect = parseSelectionSetSimple(
|
|
325
|
+
const nestedSelect = parseSelectionSetSimple(
|
|
326
|
+
fieldNode.selectionSet,
|
|
327
|
+
info,
|
|
328
|
+
excludeFields,
|
|
329
|
+
dmmf,
|
|
330
|
+
undefined,
|
|
331
|
+
);
|
|
193
332
|
|
|
194
333
|
// Extract relation arguments (where, orderBy, etc.)
|
|
195
334
|
const relationArgs = extractFieldArgs(fieldNode, variableValues);
|
|
@@ -212,14 +351,26 @@ function parseSelectionSetSimple(
|
|
|
212
351
|
const fragment = info.fragments[fragmentName];
|
|
213
352
|
|
|
214
353
|
if (fragment) {
|
|
215
|
-
const fragmentSelect = parseSelectionSetSimple(
|
|
354
|
+
const fragmentSelect = parseSelectionSetSimple(
|
|
355
|
+
fragment.selectionSet,
|
|
356
|
+
info,
|
|
357
|
+
excludeFields,
|
|
358
|
+
dmmf,
|
|
359
|
+
modelFields,
|
|
360
|
+
);
|
|
216
361
|
Object.assign(select, fragmentSelect);
|
|
217
362
|
}
|
|
218
363
|
}
|
|
219
364
|
// Handle inline fragments
|
|
220
365
|
else if (selection.kind === 'InlineFragment') {
|
|
221
366
|
if (selection.selectionSet) {
|
|
222
|
-
const inlineSelect = parseSelectionSetSimple(
|
|
367
|
+
const inlineSelect = parseSelectionSetSimple(
|
|
368
|
+
selection.selectionSet,
|
|
369
|
+
info,
|
|
370
|
+
excludeFields,
|
|
371
|
+
dmmf,
|
|
372
|
+
modelFields,
|
|
373
|
+
);
|
|
223
374
|
Object.assign(select, inlineSelect);
|
|
224
375
|
}
|
|
225
376
|
}
|
|
@@ -235,17 +386,47 @@ function parseSelectionSetSimple(
|
|
|
235
386
|
* and builds an optimal Prisma query with only the requested fields.
|
|
236
387
|
*
|
|
237
388
|
* @param info - GraphQL resolve info from the resolver
|
|
389
|
+
* @param options - Optional configuration
|
|
238
390
|
* @returns Prisma select object
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* // Automatic field filtering using Prisma DMMF (recommended):
|
|
394
|
+
* import { Prisma } from '@prisma/client';
|
|
395
|
+
* const select = transformInfoIntoPrismaArgs(info, {
|
|
396
|
+
* dmmf: Prisma.dmmf,
|
|
397
|
+
* modelName: 'User',
|
|
398
|
+
* });
|
|
399
|
+
*
|
|
400
|
+
* // Or manually exclude specific fields:
|
|
401
|
+
* const select = transformInfoIntoPrismaArgs(info, { excludeFields: ['occupationStatus'] });
|
|
239
402
|
*/
|
|
240
|
-
export function transformInfoIntoPrismaArgs(
|
|
403
|
+
export function transformInfoIntoPrismaArgs(
|
|
404
|
+
info: GraphQLResolveInfo,
|
|
405
|
+
options?: TransformOptions,
|
|
406
|
+
): PrismaSelect {
|
|
241
407
|
// Get the first field node
|
|
242
408
|
const fieldNode = info.fieldNodes[0];
|
|
243
409
|
if (!fieldNode?.selectionSet) {
|
|
244
410
|
return {};
|
|
245
411
|
}
|
|
246
412
|
|
|
413
|
+
// Convert excludeFields array to Set for O(1) lookup
|
|
414
|
+
const excludeSet = options?.excludeFields ? new Set(options.excludeFields) : undefined;
|
|
415
|
+
|
|
416
|
+
// Get model fields if dmmf and modelName are provided
|
|
417
|
+
let modelFields: ModelFieldInfo | undefined;
|
|
418
|
+
if (options?.dmmf && options?.modelName) {
|
|
419
|
+
modelFields = getModelFields(options.dmmf, options.modelName);
|
|
420
|
+
}
|
|
421
|
+
|
|
247
422
|
// Parse the selection set directly from AST
|
|
248
|
-
const select = parseSelectionSetSimple(
|
|
423
|
+
const select = parseSelectionSetSimple(
|
|
424
|
+
fieldNode.selectionSet,
|
|
425
|
+
info,
|
|
426
|
+
excludeSet,
|
|
427
|
+
options?.dmmf,
|
|
428
|
+
modelFields,
|
|
429
|
+
);
|
|
249
430
|
|
|
250
431
|
if (Object.keys(select).length === 0) {
|
|
251
432
|
return {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers-generator.js","sourceRoot":"","sources":["../../src/generator/helpers-generator.ts"],"names":[],"mappings":";;AAOA,0CAaC;AAhBD;;GAEG;AACH,SAAgB,eAAe,CAC7B,OAAgB,EAChB,MAAuB;IAEvB,MAAM,KAAK,GAAG,IAAI,GAAG,EAAsB,CAAC;IAE5C,6BAA6B;IAC7B,MAAM,WAAW,GAAG,YAAY,CAAC;IACjC,MAAM,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACnF,mBAAmB,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACzC,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IAEpC,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,SAAS,mBAAmB,CAAC,UAAsB,EAAE,OAAwB;IAC3E,UAAU,CAAC,aAAa,CAAC
|
|
1
|
+
{"version":3,"file":"helpers-generator.js","sourceRoot":"","sources":["../../src/generator/helpers-generator.ts"],"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@@ export interface GraphQLContext<PrismaClient = unknown> {
|
|
|
55
55
|
prisma: PrismaClient;
|
|
56
56
|
[key: string]: unknown;
|
|
57
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Prisma DMMF type for model field introspection
|
|
60
|
+
*/
|
|
61
|
+
export interface PrismaDMMF {
|
|
62
|
+
datamodel: {
|
|
63
|
+
models: Array<{
|
|
64
|
+
name: string;
|
|
65
|
+
fields: Array<{
|
|
66
|
+
name: string;
|
|
67
|
+
kind: string;
|
|
68
|
+
type: string;
|
|
69
|
+
}>;
|
|
70
|
+
}>;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Model field information extracted from DMMF
|
|
75
|
+
*/
|
|
76
|
+
export interface ModelFieldInfo {
|
|
77
|
+
/** Scalar field names (non-relation fields) */
|
|
78
|
+
scalars: Set<string>;
|
|
79
|
+
/** Relation field name -> related model name */
|
|
80
|
+
relations: Map<string, string>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Extract scalar and relation field names from Prisma DMMF for a model.
|
|
84
|
+
* Results are cached for performance.
|
|
85
|
+
*
|
|
86
|
+
* @param dmmf - Prisma DMMF object (import { Prisma } from '@prisma/client', use Prisma.dmmf)
|
|
87
|
+
* @param modelName - Name of the model (e.g., 'User', 'Slot')
|
|
88
|
+
* @returns ModelFieldInfo with scalars and relations
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* import { Prisma } from '@prisma/client';
|
|
93
|
+
* const fields = getModelFields(Prisma.dmmf, 'Slot');
|
|
94
|
+
* // fields.scalars: Set<string> - all scalar field names
|
|
95
|
+
* // fields.relations: Map<string, string> - relation field name -> related model name
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare function getModelFields(dmmf: PrismaDMMF, modelName: string): ModelFieldInfo;
|
|
99
|
+
/**
|
|
100
|
+
* Options for transformInfoIntoPrismaArgs
|
|
101
|
+
*/
|
|
102
|
+
export interface TransformOptions {
|
|
103
|
+
/**
|
|
104
|
+
* Fields to exclude from the Prisma select at all nesting levels.
|
|
105
|
+
* Use this for custom @ResolveField() computed fields that don't exist in Prisma.
|
|
106
|
+
* @example ['occupationStatus', 'computedField']
|
|
107
|
+
*/
|
|
108
|
+
excludeFields?: string[];
|
|
109
|
+
/**
|
|
110
|
+
* Prisma DMMF for automatic field filtering.
|
|
111
|
+
* When provided with modelName, only valid Prisma fields will be selected.
|
|
112
|
+
* @example Prisma.dmmf
|
|
113
|
+
*/
|
|
114
|
+
dmmf?: PrismaDMMF;
|
|
115
|
+
/**
|
|
116
|
+
* Root model name for automatic field filtering.
|
|
117
|
+
* Used with dmmf to filter out non-Prisma fields recursively.
|
|
118
|
+
* @example 'User'
|
|
119
|
+
*/
|
|
120
|
+
modelName?: string;
|
|
121
|
+
}
|
|
58
122
|
/**
|
|
59
123
|
* Transform GraphQL resolve info into Prisma select/include arguments
|
|
60
124
|
*
|
|
@@ -62,6 +126,7 @@ export interface GraphQLContext<PrismaClient = unknown> {
|
|
|
62
126
|
* and builds an optimal Prisma query with only the requested fields.
|
|
63
127
|
*
|
|
64
128
|
* @param info - GraphQL resolve info from the resolver
|
|
129
|
+
* @param options - Optional configuration
|
|
65
130
|
* @returns Prisma select object
|
|
66
131
|
*
|
|
67
132
|
* @example
|
|
@@ -73,9 +138,19 @@ export interface GraphQLContext<PrismaClient = unknown> {
|
|
|
73
138
|
* ...select,
|
|
74
139
|
* });
|
|
75
140
|
* }
|
|
141
|
+
*
|
|
142
|
+
* // Automatic field filtering using Prisma DMMF (recommended):
|
|
143
|
+
* import { Prisma } from '@prisma/client';
|
|
144
|
+
* const select = transformInfoIntoPrismaArgs(info, {
|
|
145
|
+
* dmmf: Prisma.dmmf,
|
|
146
|
+
* modelName: 'User',
|
|
147
|
+
* });
|
|
148
|
+
*
|
|
149
|
+
* // Or manually exclude specific fields:
|
|
150
|
+
* const select = transformInfoIntoPrismaArgs(info, { excludeFields: ['occupationStatus'] });
|
|
76
151
|
* ```
|
|
77
152
|
*/
|
|
78
|
-
export declare function transformInfoIntoPrismaArgs(info: GraphQLResolveInfo): PrismaSelect;
|
|
153
|
+
export declare function transformInfoIntoPrismaArgs(info: GraphQLResolveInfo, options?: TransformOptions): PrismaSelect;
|
|
79
154
|
/**
|
|
80
155
|
* Transform GraphQL resolve info into Prisma aggregate arguments
|
|
81
156
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/runtime/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAa,kBAAkB,EAA+B,MAAM,SAAS,CAAC;AAE1F;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,cAAc,CAAC,CAAC;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,cAAc,CAAC,CAAC;CACpD;AAED;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,YAAY;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3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AE,CAAC;IAEzB;;;;OAIG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAElB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA+MD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,kBAAkB,EACxB,OAAO,CAAC,EAAE,gBAAgB,GACzB,YAAY,CA8Bd;AAOD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oCAAoC,CAClD,IAAI,EAAE,kBAAkB,GACvB,mBAAmB,CAyDrB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,GAAG,OAAO,EACzD,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,GACpC,YAAY,CASd;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,OAAO,EAAE,YAAY,EAAE,GAAG,YAAY,CAO3E"}
|
package/dist/runtime/helpers.js
CHANGED
|
@@ -9,10 +9,54 @@
|
|
|
9
9
|
* without relying on schema type introspection.
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getModelFields = getModelFields;
|
|
12
13
|
exports.transformInfoIntoPrismaArgs = transformInfoIntoPrismaArgs;
|
|
13
14
|
exports.transformInfoIntoPrismaAggregateArgs = transformInfoIntoPrismaAggregateArgs;
|
|
14
15
|
exports.getPrismaFromContext = getPrismaFromContext;
|
|
15
16
|
exports.mergePrismaSelects = mergePrismaSelects;
|
|
17
|
+
/**
|
|
18
|
+
* Cache for model fields extracted from DMMF
|
|
19
|
+
*/
|
|
20
|
+
const modelFieldsCache = new Map();
|
|
21
|
+
/**
|
|
22
|
+
* Extract scalar and relation field names from Prisma DMMF for a model.
|
|
23
|
+
* Results are cached for performance.
|
|
24
|
+
*
|
|
25
|
+
* @param dmmf - Prisma DMMF object (import { Prisma } from '@prisma/client', use Prisma.dmmf)
|
|
26
|
+
* @param modelName - Name of the model (e.g., 'User', 'Slot')
|
|
27
|
+
* @returns ModelFieldInfo with scalars and relations
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* import { Prisma } from '@prisma/client';
|
|
32
|
+
* const fields = getModelFields(Prisma.dmmf, 'Slot');
|
|
33
|
+
* // fields.scalars: Set<string> - all scalar field names
|
|
34
|
+
* // fields.relations: Map<string, string> - relation field name -> related model name
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
function getModelFields(dmmf, modelName) {
|
|
38
|
+
const cacheKey = modelName;
|
|
39
|
+
if (modelFieldsCache.has(cacheKey)) {
|
|
40
|
+
return modelFieldsCache.get(cacheKey);
|
|
41
|
+
}
|
|
42
|
+
const model = dmmf.datamodel.models.find(m => m.name === modelName);
|
|
43
|
+
if (!model) {
|
|
44
|
+
throw new Error(`Model "${modelName}" not found in Prisma DMMF`);
|
|
45
|
+
}
|
|
46
|
+
const scalars = new Set();
|
|
47
|
+
const relations = new Map();
|
|
48
|
+
for (const field of model.fields) {
|
|
49
|
+
if (field.kind === 'object') {
|
|
50
|
+
relations.set(field.name, field.type);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
scalars.add(field.name);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const info = { scalars, relations };
|
|
57
|
+
modelFieldsCache.set(cacheKey, info);
|
|
58
|
+
return info;
|
|
59
|
+
}
|
|
16
60
|
/**
|
|
17
61
|
* Fields that should be excluded from selection
|
|
18
62
|
* These are GraphQL internal fields or aggregation fields
|
|
@@ -81,8 +125,9 @@ function extractFieldArgs(fieldNode, variableValues) {
|
|
|
81
125
|
* Parse a selection set into a Prisma select object
|
|
82
126
|
* This function works directly with the AST without schema type introspection.
|
|
83
127
|
* It also extracts relation arguments (where, orderBy, take, skip, cursor, distinct).
|
|
128
|
+
* When dmmf and modelFields are provided, filters out fields not in Prisma model.
|
|
84
129
|
*/
|
|
85
|
-
function parseSelectionSetSimple(selectionSet, info) {
|
|
130
|
+
function parseSelectionSetSimple(selectionSet, info, excludeFields, dmmf, modelFields) {
|
|
86
131
|
const select = {};
|
|
87
132
|
if (!selectionSet) {
|
|
88
133
|
return select;
|
|
@@ -93,14 +138,42 @@ function parseSelectionSetSimple(selectionSet, info) {
|
|
|
93
138
|
if (selection.kind === 'Field') {
|
|
94
139
|
const fieldNode = selection;
|
|
95
140
|
const fieldName = fieldNode.name.value;
|
|
96
|
-
// Skip excluded fields
|
|
97
|
-
if (EXCLUDED_FIELDS.has(fieldName)) {
|
|
141
|
+
// Skip excluded fields (internal + user-specified)
|
|
142
|
+
if (EXCLUDED_FIELDS.has(fieldName) || excludeFields?.has(fieldName)) {
|
|
98
143
|
continue;
|
|
99
144
|
}
|
|
100
|
-
//
|
|
145
|
+
// If modelFields provided, filter based on Prisma model schema
|
|
146
|
+
if (modelFields) {
|
|
147
|
+
const isScalar = modelFields.scalars.has(fieldName);
|
|
148
|
+
const isRelation = modelFields.relations.has(fieldName);
|
|
149
|
+
if (!isScalar && !isRelation) {
|
|
150
|
+
// Field doesn't exist in Prisma model - skip it (custom @ResolveField)
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
if (isRelation && fieldNode.selectionSet && dmmf) {
|
|
154
|
+
// For relations, recursively get related model's fields
|
|
155
|
+
const relatedModelName = modelFields.relations.get(fieldName);
|
|
156
|
+
const relatedModelFields = getModelFields(dmmf, relatedModelName);
|
|
157
|
+
const nestedSelect = parseSelectionSetSimple(fieldNode.selectionSet, info, excludeFields, dmmf, relatedModelFields);
|
|
158
|
+
const relationArgs = extractFieldArgs(fieldNode, variableValues);
|
|
159
|
+
if (Object.keys(nestedSelect).length > 0) {
|
|
160
|
+
select[fieldName] = { select: nestedSelect, ...relationArgs };
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
select[fieldName] = Object.keys(relationArgs).length > 0 ? { ...relationArgs } : true;
|
|
164
|
+
}
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
// Scalar field
|
|
168
|
+
if (isScalar) {
|
|
169
|
+
select[fieldName] = true;
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// Fallback: no modelFields filtering (original behavior)
|
|
101
174
|
if (fieldNode.selectionSet) {
|
|
102
175
|
// Recursively parse nested selections
|
|
103
|
-
const nestedSelect = parseSelectionSetSimple(fieldNode.selectionSet, info);
|
|
176
|
+
const nestedSelect = parseSelectionSetSimple(fieldNode.selectionSet, info, excludeFields, dmmf, undefined);
|
|
104
177
|
// Extract relation arguments (where, orderBy, etc.)
|
|
105
178
|
const relationArgs = extractFieldArgs(fieldNode, variableValues);
|
|
106
179
|
if (Object.keys(nestedSelect).length > 0) {
|
|
@@ -120,14 +193,14 @@ function parseSelectionSetSimple(selectionSet, info) {
|
|
|
120
193
|
const fragmentName = selection.name.value;
|
|
121
194
|
const fragment = info.fragments[fragmentName];
|
|
122
195
|
if (fragment) {
|
|
123
|
-
const fragmentSelect = parseSelectionSetSimple(fragment.selectionSet, info);
|
|
196
|
+
const fragmentSelect = parseSelectionSetSimple(fragment.selectionSet, info, excludeFields, dmmf, modelFields);
|
|
124
197
|
Object.assign(select, fragmentSelect);
|
|
125
198
|
}
|
|
126
199
|
}
|
|
127
200
|
// Handle inline fragments
|
|
128
201
|
else if (selection.kind === 'InlineFragment') {
|
|
129
202
|
if (selection.selectionSet) {
|
|
130
|
-
const inlineSelect = parseSelectionSetSimple(selection.selectionSet, info);
|
|
203
|
+
const inlineSelect = parseSelectionSetSimple(selection.selectionSet, info, excludeFields, dmmf, modelFields);
|
|
131
204
|
Object.assign(select, inlineSelect);
|
|
132
205
|
}
|
|
133
206
|
}
|
|
@@ -141,6 +214,7 @@ function parseSelectionSetSimple(selectionSet, info) {
|
|
|
141
214
|
* and builds an optimal Prisma query with only the requested fields.
|
|
142
215
|
*
|
|
143
216
|
* @param info - GraphQL resolve info from the resolver
|
|
217
|
+
* @param options - Optional configuration
|
|
144
218
|
* @returns Prisma select object
|
|
145
219
|
*
|
|
146
220
|
* @example
|
|
@@ -152,16 +226,33 @@ function parseSelectionSetSimple(selectionSet, info) {
|
|
|
152
226
|
* ...select,
|
|
153
227
|
* });
|
|
154
228
|
* }
|
|
229
|
+
*
|
|
230
|
+
* // Automatic field filtering using Prisma DMMF (recommended):
|
|
231
|
+
* import { Prisma } from '@prisma/client';
|
|
232
|
+
* const select = transformInfoIntoPrismaArgs(info, {
|
|
233
|
+
* dmmf: Prisma.dmmf,
|
|
234
|
+
* modelName: 'User',
|
|
235
|
+
* });
|
|
236
|
+
*
|
|
237
|
+
* // Or manually exclude specific fields:
|
|
238
|
+
* const select = transformInfoIntoPrismaArgs(info, { excludeFields: ['occupationStatus'] });
|
|
155
239
|
* ```
|
|
156
240
|
*/
|
|
157
|
-
function transformInfoIntoPrismaArgs(info) {
|
|
241
|
+
function transformInfoIntoPrismaArgs(info, options) {
|
|
158
242
|
// Get the first field node
|
|
159
243
|
const fieldNode = info.fieldNodes[0];
|
|
160
244
|
if (!fieldNode?.selectionSet) {
|
|
161
245
|
return {};
|
|
162
246
|
}
|
|
247
|
+
// Convert excludeFields array to Set for O(1) lookup
|
|
248
|
+
const excludeSet = options?.excludeFields ? new Set(options.excludeFields) : undefined;
|
|
249
|
+
// Get model fields if dmmf and modelName are provided
|
|
250
|
+
let modelFields;
|
|
251
|
+
if (options?.dmmf && options?.modelName) {
|
|
252
|
+
modelFields = getModelFields(options.dmmf, options.modelName);
|
|
253
|
+
}
|
|
163
254
|
// Parse the selection set directly from AST
|
|
164
|
-
const select = parseSelectionSetSimple(fieldNode.selectionSet, info);
|
|
255
|
+
const select = parseSelectionSetSimple(fieldNode.selectionSet, info, excludeSet, options?.dmmf, modelFields);
|
|
165
256
|
if (Object.keys(select).length === 0) {
|
|
166
257
|
return {};
|
|
167
258
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/runtime/helpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/runtime/helpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AAsGH,wCAyBC;AAwQD,kEAiCC;AA2BD,oFA2DC;AAkBD,oDAWC;AAQD,gDAOC;AAzdD;;GAEG;AACH,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAA0B,CAAC;AAE3D;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,cAAc,CAAC,IAAgB,EAAE,SAAiB;IAChE,MAAM,QAAQ,GAAG,SAAS,CAAC;IAC3B,IAAI,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;QACnC,OAAO,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC;IACzC,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;IACpE,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,UAAU,SAAS,4BAA4B,CAAC,CAAC;IACnE,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;IAE5C,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QACjC,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC5B,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACxC,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IAED,MAAM,IAAI,GAAmB,EAAE,O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,SAAgB,kBAAkB,CAAC,GAAG,OAAuB;IAC3D,MAAM,MAAM,GAAiB,EAAE,CAAC;IAChC,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,CAAC,MAAM;YAAE,MAAM,CAAC,MAAM,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;QACxE,IAAI,CAAC,CAAC,OAAO;YAAE,MAAM,CAAC,OAAO,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;IAC9E,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@k0lyan/nestjs-prisma-graphql-generator",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.6",
|
|
4
4
|
"description": "Prisma generator for NestJS 11 GraphQL with optimized query building from GraphQL selections",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|