【问题标题】:how to convert the type of a column out of a orm into a graphql type?如何将orm中的列类型转换为graphql类型?
【发布时间】:2021-03-16 08:16:15
【问题描述】:
如何获取从列中获取的类型并将其转换为 GraphQL 类型?
例如将 String 类型转换为 GraphQLString,将 Number 类型转换为 GraphQLString,等等
我的价值示例:
firstName: { type: [Function: String] },
我必须用 GraphQL 值映射列的值吗?
【问题讨论】:
标签:
typescript
metadata
typeorm
graphql-js
converters
【解决方案1】:
这对我有用.. 将 @Field 装饰器添加到模型列 def...
@Field(() => String)
@Column("char", { name: "remarks", nullable: true, length: 31 })
remarks: string | null;
导入自
import {Field, Int, ObjectType} from "type-graphql";