【问题标题】:How to use simple-json with intergers in type-graphql如何在 type-graphql 中使用带整数的 simple-json
【发布时间】:2021-03-23 03:01:54
【问题描述】:

我尝试了许多不同的方法来使用 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;
}

【问题讨论】:

  • "自定义 json 标量" ... graphql-type-json ?

标签: node.js typescript express graphql typegraphql


【解决方案1】:

您需要使用 GraphQL JSON 标量,例如来自graphql-type-json 图书馆的那个。

【讨论】:

    猜你喜欢
    • 2017-07-10
    • 2021-06-25
    • 1970-01-01
    • 2020-04-28
    • 2020-02-27
    • 2011-01-13
    • 1970-01-01
    • 2018-10-11
    • 1970-01-01
    相关资源
    最近更新 更多