1.0.3 • Published 1 year ago

add-fields v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

add-field

A tool to automatically add @Field decorators to TypeScript classes with @ObjectType, @InputType, and @ArgsType decorators.

Installation

You can use this tool directly with npx:

Example

Given the following class:

@InputType()
class CreateUserInput {
  id: number;
  name: string;
  email: string;
  password: string;
  account: Account;
  orders?: Order[];
  scores: number[];
  isAdmin: boolean;
}

After running the tool:

npx add-field src/**/*.ts

The class will be transformed into:

@InputType()
class CreateUserInput {
  @Field()
  id: number;
  @Field()
  name: string;
  @Field()
  email: string;
  @Field()
  password: string;
  @Field(() => Account)
  account: Account;
  @Field(() => [Order], { nullable: true })
  orders?: Order[];
  @Field(() => [Number])
  scores: number[];
  @Field()
  isAdmin: boolean;
}
1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago