Should I use { isAbstract: true } ? #1074
-
BaseEntity.ts: import { BaseEntity as Base, PrimaryKey, Property } from "@mikro-orm/core";
import { Field, ID, ObjectType } from "type-graphql";
// Should I be using { isAbstract: true } here?? Since I'm never planning on registering this type in my schema
// and only extending it, I don't think it's needed
@ObjectType()
export abstract class BaseEntity<T extends BaseEntity<T>> extends Base<
T,
"id"
> {
@Field(() => ID)
@PrimaryKey()
readonly id!: number;
@Field()
@Property()
readonly createdAt: Date = new Date();
@Field()
@Property({ onUpdate: () => new Date() })
readonly updatedAt: Date = new Date();
} User.ts: import { Entity, Property, Unique } from "@mikro-orm/core";
import { Field, ObjectType } from "type-graphql";
import { BaseEntity } from "./BaseEntity";
@ObjectType()
@Entity()
export class User extends BaseEntity<User> {
@Field()
@Property()
name!: string;
@Field()
@Property()
@Unique()
email!: string;
@Property()
password!: string;
@Field()
@Property()
image!: string;
} |
Beta Was this translation helpful? Give feedback.
Answered by
MichalLytek
Oct 14, 2021
Replies: 1 comment 1 reply
-
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Axedyson
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
isAbstract: true
is a legacy syntax that can be used when you use theresolvers
string paths array approach forbuildSchema
.