prisma-nestjs-graphql
Generate object types, inputs, args, etc. from prisma schema file for usage with @nestjs/graphql module.
Features
- Generates only necessary imports
- Combines zoo of nested/nullable filters
- Updates source code of existing files
- Do not generate resolvers, since it's application specific
Install
npm install --save-dev prisma-nestjs-graphql
Usage
- Add new generator section to
schema.prisma
file
generator nestgraphql {
provider = "node node_modules/prisma-nestjs-graphql"
output = "../src"
}
- Run prisma generate
npx prisma generate
Generator options
-
output
Output folder relative to this schema file
-
outputFilePattern
File pattern (default: {feature}/{name}.{type}.ts
)
Possible tokens:
{feature}
- 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)
-
combineScalarFilters
- Combine nested/nullable scalar filters to single
(default: true
)
-
atomicNumberOperations
- Atomic number operations,
false
- disabled (default), true
- enabled
-
types_*
- flatten map of types
types_{type}_fieldType
- TypeScript type nametypes_{type}_fieldModule
- Module to importtypes_{type}_graphqlType
- GraphQL type nametypes_{type}_graphqlModule
- Module to import
Where {type}
is prisma type in schema
Example:
types_Decimal_fieldType = "Decimal"
types_Decimal_fieldModule = "decimal.js"
types_Decimal_graphqlType = "GraphQLDecimal"
types_Decimal_graphqlModule = "graphql-type-decimal"
Generates field:
import { GraphQLDecimal } from 'graphql-type-decimal';
import { Decimal } from 'decimal.js';
...
@Field(() => GraphQLDecimal)
field: Decimal;
Similar Projects
Resources