Output folder relative to this schema file
Type: string
outputFilePattern
File path and name pattern
Type: string
Default: {model}/{name}.{type}.ts
Possible tokens:
{model} Model name in dashed case or 'prisma' if unknown
{name} Dashed-case name of model/input/arg without suffix
{type} Short type name (model, input, args, output)
{plural.type} Plural short type name (models, inputs, enums)
tsConfigFilePath
Path to tsconfig.json (absolute path or relative to current working directory)
Type: string | undefined
Default: tsconfig.json if exists, undefined otherwise
combineScalarFilters
Combine nested/nullable scalar filters to single
Type: boolean
Default: false
noAtomicOperations
Remove input types for atomic operations
Type: boolean
Default: false
reExport
Create index.ts file with re-export
Type: enum
Values: None Default, create nothing Directories Create index file in all root directories Single Create single index file in output directory All Create index file in all root directories and in output directory
Generate single file with merged classes and enums.
Type: boolean
Default: false
emitCompiled
Emit compiled JavaScript and definitions instead of TypeScript sources,
files will be compiled with emitDecoratorMetadata:false, because there is a problem
with temporal dead zone when generating merged file.
Type: boolean
Default: false
purgeOutput
Delete all files in output folder
Type: boolean
Default: false
noTypeId
Disable usage of graphql ID type and use Int/Float for fields marked as @id in schema.
Type: boolean
Default: false
requireSingleFieldsInWhereUniqueInput
When a model *WhereUniqueInput class has only a single field, mark that field as required (TypeScript) and not nullable (GraphQL).
See #58 for more details.
Type: boolean
Default: false Note: It will break compatiblity between Prisma types and generated classes.
useInputType
Since GraphQL does not support input union type, this setting map
allow to choose which input type is preferable.
typeName Full name or partial name of the class where need to choose input type.
Example: UserCreateInput full name, WhereInput partial name, matches UserWhereInput, PostWhereInput, etc.
property Property of the class for which need to choose type. Special case name ALL means any / all properties.
pattern Part of name (or full) of type which should be chosen, you can use
wild card or negate symbols, in this case pattern should starts with match:,
e.g. match:*UncheckedCreateInput see outmatch for details.
We have generated types above, by default property author will be decorated as UserRelationFilter,
to set UserWhereInput need to configure generator the following way:
To make it validateable (assuming UserCreateInput already contains validation decorators from class-validator),
it is necessary to add @ValidateNested() and @Type() from class-transformer.
It will affect all inputs and outputs types (including models).
Documentation and field options
Comments with triple slash will projected to typescript code comments
and some @Field() decorator options
For example:
modelProduct {/// Old description/// @deprecated Use new name insteadoldNameString}
May produce:
@ObjectType()exportclassProduct{/** * Old description * @deprecated Use new name instead */
@Field(()=>String,{description: 'Old description',deprecationReason: 'Use new name instead',})oldName: string;}
Field Settings
Special directives in triple slash comments for more precise code generation.
@HideField()
Removes field from GraphQL schema.
Alias: @TypeGraphQL.omit(output: true)
By default (without arguments) field will be decorated for hide only in output types (type in schema).
To hide field in input types add input: true.
To hide field in specific type you can use glob pattern match: string | string[]
see outmatch for details.
Create configuration map in flatten style for {namespace}.
Where {namespace} is a namespace used in field triple slash comment.
fields_{namespace}_from
Required. Name of the module, which will be used in import (class-validator, graphql-scalars, etc.)
Type: string
fields_{namespace}_input
Means that it will be applied on input types (classes decorated by InputType)
Type: boolean
Default: false
fields_{namespace}_output
Means that it will be applied on output types (classes decorated by ObjectType),
including models
Type: boolean
Default: false
fields_{namespace}_model
Means that it will be applied only on model types (classes decorated by ObjectType)
Type: boolean
Default: false
fields_{namespace}_defaultImport
Default import name, if module have no namespace.
Type: undefined | string | true
Default: undefined
If defined as true then import name will be same as {namespace}
fields_{namespace}_namespaceImport
Import all as this namespace from module
Type: undefined | string
Default: Equals to {namespace}
fields_{namespace}_namedImport
If imported module has internal namespace, this allow to generate named import,
imported name will be equal to {namespace}, see example of usage
Type: boolean
Default: false
请发表评论