Type-graphql: Support entity inheritance

Created on 13 Aug 2018  路  1Comment  路  Source: MichalLytek/type-graphql

In order to maintain a large number of entities it would be beneficial to be able to use inheritance to not have to redefine entity fields.

The following demonstrates this:

class BaseEntity {
  @Field({ description: "The identifier of the entity." })
  public id: string;

  @Field({ description: "The time at which the entity was created." })
  public createdAt: Date;

  @Field({ description: "The time at which the entity was updated." })
  public updatedAt: Date;
}

@ObjectType({ description: "A user" })
export User extends Model {
  @Field({ description: "The name of the user." })
  public name: string = "";
}
Question Solved

Most helpful comment

My bad. Decorating the base class with ObjectType will make this work.

>All comments

My bad. Decorating the base class with ObjectType will make this work.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

glentakahashi picture glentakahashi  路  3Comments

limenutt picture limenutt  路  3Comments

laukaichung picture laukaichung  路  3Comments

tongtwist picture tongtwist  路  3Comments

Asim13se picture Asim13se  路  3Comments