Backend

NestJS specific style guide and conventions

Entities

Node

Entities should always extend Node unless it is absolutely not possible.

@ObjectType()
@Entity('addresses')
export class Address extends Node {
    ....
}

Decorators

Decorators must be placed in the following order

  1. Any other decorators, such as type validators (e.g. IsPhoneNumber)

  2. GraphQL Field decorator

  3. TypeORM Column decorator

Descriptions

All Field decorators must supply the description property.

Resolvers

A resolver can be:

  • A mutation

  • A query

  • A field

A resolver file must not contain more than 1 mutation.

A resolver file should not contain more than 1 query.

A resolver file may contain more than 1 field resolver.

Last updated

Was this helpful?