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

235 Views Asked by At

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;
}
1

There are 1 best solutions below

0
On BEST ANSWER

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