Object & CRUD Generation
Steps:
- DMMF taken from
options.dmmfwhen Prisma supplies it, avoiding a redundant re-parse of the schema;getDMMF({ datamodel, previewFeatures })is only used as a fallback. - Input object & model operation lists cloned.
- Hidden models/fields resolved from model comments.
- Missing input object types added (legacy support) before filtering.
- Object schemas generated if
emit.objectsand not pure-only heuristics; each object pre-filtered withfilterFields. - CRUD operation schemas assembled (model args, aggregate support) if
emit.crud. - Objects index synthesized (for integration consistency).
isObjectSchemaEnabled checks model enablement + required operations + minimal mode pruning heuristics.
Aggregate result schemas produced via generateResultSchemas (if results not forcibly disabled).
Generated Shapes
A few details of the assembled schemas are worth knowing when you read the output:
-
Select schemas accept nested relation args. A relation field in a
selectis a union, not a bare boolean, so you can pass query arguments through it (here for aFormmodel with alayoutsrelation):layouts: z.union([z.boolean(), z.lazy(() => LayoutFindManySchema)]).optional(),
_count: z.union([z.boolean(), z.lazy(() => FormCountOutputTypeArgsObjectSchema)]).optional(), -
Relation fields in
Create*andUnchecked*Inputkeep DMMF optionality.schema.inputObjectTypesis the source of truth, because that is what the Prisma Client input types are generated from. The datamodel recompute may only relax requiredness (a field with a database default becomes optional); it never promotes a DMMF-optional field to required. List fields are always treated as optional, matching the client's input types. -
Result schemas reference pure models for relations. When
pureModelsis enabled, a relation field is typed asz.array(<Model>Schema).optional()or<Model>Schema.optional()and imported from../models/. Self-relations, runs without pure models, and single-file mode fall back toz.array(z.unknown()).optional()/z.unknown().optional(). Relation fields are always.optional()because they are only present when the queryincludes them. -
Prismais only imported when it is used.import type { Prisma }is emitted only when the file's typed export actually referencesPrisma, so files that do not need it no longer carry an unused import. IndecimalMode: "decimal"it becomes a value import instead, sincePrisma.Decimal.isDecimalchecks and Decimal defaults need the runtime value.