2.1.6 • Published 2 years ago
@jmondi/prisma-generator-nestjs-graphql v2.1.6
@jmondi/prisma-generator-nestjs-graphql
Generate @nestjs/graphql entities and create/update inputs
Install
pnpm add @jmondi/prisma-generator-nestjs-graphql
Usage
generator custom_generator {
provider = "generate-nestjs-models"
clientPath = "@prisma/client"
output = "../generated"
prefix = "Base"
abstract = false
compileJs = false
}
You can also run the generator directly
generator custom_generator {
provider = "ts-node node_modules/@jmondi/prisma-generator-nestjs-graphql/src/generator.ts"
...
}
See the generated examples for sample output.
Why?
The special sauce here is the type-safe constructors.
constructor(model: UserConstructor) {
this.id = model.id ?? uuid();
this.email = model.email;
this.passwordHash = model.passwordHash ?? null;
this.tokenVersion = model.tokenVersion ?? 0;
this.lastLoginAt = model.lastLoginAt ?? null;
this.createdIP = model.createdIP;
this.createdAt = model.createdAt ?? new Date();
this.updatedAt = model.updatedAt ?? null;
this.posts = model.posts ?? null;
}
Create your own entities by extending the generated base entities.
export class User extends BaseUser {}
Extend your custom entities with additional fields.
export abstract class UserTokenEntity extends BaseUserToken {
@Field(() => User, { nullable: true })
user!: null | User;
constructor(props: UserTokenConstructor) {
props.user = props.user ? new User(props.user) : undefined;
super(props);
}
}
Debug?
DEBUG=* pnpm prisma generate
2.0.0-beta.9
2 years ago
2.0.0-beta.8
2 years ago
2.0.0-beta.7
2 years ago
1.5.2
2 years ago
1.5.1
2 years ago
1.5.0
2 years ago
2.1.2
2 years ago
2.1.1
2 years ago
2.1.3
2 years ago
2.1.6
2 years ago
2.1.5
2 years ago
2.0.0-beta.1
2 years ago
2.0.0-beta.6
2 years ago
2.1.0
2 years ago
2.0.0
2 years ago
2.0.0-beta.3
2 years ago
1.2.0
3 years ago
1.1.1
3 years ago
1.1.0
3 years ago
1.0.1
3 years ago
1.0.0
3 years ago
1.4.1
3 years ago
1.4.0
3 years ago
1.2.2
3 years ago
1.3.0
3 years ago
1.2.1
3 years ago
1.1.2
3 years ago
1.0.0-rc.13
3 years ago
1.0.0-rc.12
3 years ago
1.0.0-rc.9
3 years ago
1.0.0-rc.8
3 years ago
1.0.0-rc.10
3 years ago
1.0.0-rc.4
3 years ago
1.0.0-rc.2
3 years ago
1.0.0-rc.1
3 years ago