Im using typeorm and typegraphql to build an API and I would like to abstract out properties of an entity into separate files and then import them to clean up the file:
Example of current
@Entity()
@ObjectType()
export class Person extends BaseEntity {
@Field()
@Column()
name: string;
@Field()
@Column()
surname: string;
@Field()
@Column()
age: number;
@Field()
@Column()
email: string;
}
I would like to do something like this:
class Name {
@Field()
@Column()
name: string;
@Field()
@Column()
surname: string;
}
@Entity()
@ObjectType()
export class Person extends BaseEntity {
@Field()
@Column()
age: number;
@Field()
@Column()
email: string;
// then import the class here
...Name
}
Is there any way to do this without creating separate entities and tables?