如何在 type-graphql 中使用带有整数的 simple-json
How to use simple-json with intergers in type-graphql
我尝试了很多不同的方法来使用 simple-json 作为实体上的整数类型。
@ObjectType()
@Entity()
export default class PlayerEntity extends BaseEntity {
@Field(() => Int)
@PrimaryGeneratedColumn()
id: number;
@Column()
@Field()
username: string;
@Column({ type: "simple-json" })
@Field()
info: Info;
}
Info 看起来像
@InputType()
@ObjectType()
export default class Info {
@Field()
address: string;
@Field(() => Int)
house_number: number;
}
您需要使用 GraphQL JSON 标量,例如来自 graphql-type-json
图书馆的那个。
我尝试了很多不同的方法来使用 simple-json 作为实体上的整数类型。
@ObjectType()
@Entity()
export default class PlayerEntity extends BaseEntity {
@Field(() => Int)
@PrimaryGeneratedColumn()
id: number;
@Column()
@Field()
username: string;
@Column({ type: "simple-json" })
@Field()
info: Info;
}
Info 看起来像
@InputType()
@ObjectType()
export default class Info {
@Field()
address: string;
@Field(() => Int)
house_number: number;
}
您需要使用 GraphQL JSON 标量,例如来自 graphql-type-json
图书馆的那个。