【发布时间】:2020-03-25 04:40:40
【问题描述】:
我想为 Hasura 生成的 graphql 模式中的特定字段覆盖 jsonb 类型,并通过 graphql-code-generator 运行。
我有一个 jsonb 类型的 customList 字段。 ths 用于包含一个 json 对象数组。当使用带有 TypeScript 插件的 graphql-code-generator 时,生成的类型解析为 any。我试图弄清楚如何仅使用该特定字段的自定义类型来覆盖它。
下面的 sn-ps 显示了 graphql 模式的相关部分,并覆盖了目标 graphql 类型。到目前为止,我尝试过的所有操作都会导致代码生成错误
GraphQl 架构
//schema.json
...
{
"kind": "OBJECT",
"name": “MyEntity”,
"description": "columns and relationships of MyEntity",
"fields": [
...
{
"name": "customList",
"description": "",
"args": [
{
"name": "path",
"description": "JSON select path",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null
}
],
"type": {
"kind": "SCALAR",
"name": "jsonb",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
}
}
目标覆盖类型
//clientTypes.graphql
type ListItem {
itemId: string!
}
extend type MyEntity {
ccards: [ListItem!]
}
感谢您的帮助!
【问题讨论】:
标签: typescript graphql hasura graphql-codegen