Graphql 在内省时获取必需/非空字段
我正在使用一个内省来查询输入类型,以创建一个表单来更改一个实体Graphql 在内省时获取必需/非空字段,graphql,Graphql,我正在使用一个内省来查询输入类型,以创建一个表单来更改一个实体 query introspection($updateInputName: String!) { __type(name: $updateInputName) { inputFields { name type { name kind ofType { kind name } }
query introspection($updateInputName: String!) {
__type(name: $updateInputName) {
inputFields {
name
type {
name
kind
ofType {
kind
name
}
}
}
}
}
据我所知,type.kind信息应该为必填/非NULL字段返回非NULL。但是我收到了标量
如何获取查询的inputField所需字段的相关信息?如果字段不可为空,则
类
字段确实将解析为非空
。如果您看到的是标量,则该字段可为空
以下是每种包装类型组合的内省结果:
Int
"type": {
"name": "Int",
"kind": "SCALAR",
"ofType": null
}
Int代码>
"type": {
"name": null,
"kind": "NON_NULL",
"ofType": {
"name": "Int",
"kind": "SCALAR",
"ofType": null
}
}
[Int!]
"type": {
"name": null,
"kind": "LIST",
"ofType": {
"name": null,
"kind": "NON_NULL",
"ofType": {
"name": "Int",
"kind": "SCALAR",
"ofType": null
}
},
}
[Int代码>
"type": {
"name": null,
"kind": "NON_NULL",
"ofType": {
"name": null,
"kind": "LIST",
"ofType": {
"name": null,
"kind": "NON_NULL",
"ofType": {
"name": "Int",
"kind": "SCALAR",
"ofType": null
}
},
}
}
你说得对。我看错了我的模式类型,弄糊涂了。