Is there a way to create a custom class-level decorator that adds two parameters to a TypeGraphQL
@ObjectType
class?
Example:
@ObjectType()
@Timestampable // custom decorator
class User {
@Field()
email: string;
}
The @Timestampable
decorator should add the createdAt
and updatedAt
props to the User
class and the new props should show up in the gql
schema.
I am trying to avoid doing this:
@ObjectType()
@Timestampable
class User {
@Field()
email: string;
@Field(() => Date)
createdAt: Date;
@Field(() => Date)
updatedAt: Date;
}
If yes, then is it possible to stack multiple decorators like this:
@ObjectType()
@Timestampable
@Blamable
class User {
...
}
Do you know a better way to achieve this?