How to use the warthog.EnumField function in warthog

To help you get started, we’ve selected a few warthog examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github goldcaddy77 / warthog-starter / src / user.model.ts View on Github external
// Note: this must be exported and in the same file where it's attached with @EnumField
// Also - must use string enums
export enum UserStatus {
  ACTIVE = 'ACTIVE',
  INACTIVE = 'INACTIVE'
}

@Model()
export class User extends BaseModel {
  @StringField({ maxLength: 30 })
  firstName?: string;

  @StringField({ maxLength: 50, minLength: 2, nullable: true })
  lastName?: string;

  @EnumField('UserStatus', UserStatus)
  status?: UserStatus;

  @EmailField() email?: string;

  @OneToMany(() => Post, (post: Post) => post.user)
  posts?: Post[];
}

warthog

Opinionated set of tools for setting up GraphQL backed by TypeORM

MIT
Latest version published 4 years ago

Package Health Score

42 / 100
Full package analysis