简体   繁体   中英

How to use simple-json with intergers in type-graphql

I tried many different things to use simple-json as a type with integers on entities.

@ObjectType()
@Entity()
export default class PlayerEntity extends BaseEntity {
    @Field(() => Int)
    @PrimaryGeneratedColumn()
    id: number;

    @Column()
    @Field()
    username: string;

    @Column({ type: "simple-json" })
    @Field()
    info: Info;
}

and Info would've looked something like

@InputType()
@ObjectType()
export default class Info {
    @Field()
    address: string;

    @Field(() => Int)
    house_number: number;
}

You need to use GraphQL JSON scalar, eg the one from graphql-type-json library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM