json - 如果每个子列表的至少一个元素包含查询的字段,graphiql 才允许查询
问题描述
我正在使用 graphiQL 来调试我的 react 项目的 graphql 查询。
这是我的查询:
{
testdataJson{
E{
D{
A
B
entries
}
}
}
}
在数据集 testdata.json 上:
{
"E": [
{
"D": [
[
{
"A": "Y1",
"entries": [
"Z1"
]
},
{
"A": "Y2",
"entries": [
"Z2"
]
}
],
[
{
"A": "Y3",
"entries": [
"Z3"
]
},
{
"A": "Y4",
"entries": [
"Z4"
],
"B": true
}
],
[
{
"A": "Y5",
"entries": [
"Z5"
],
"B": true
}
]
]
}
]
}
这给出了错误:Cannot query field \"B\" on type \"TestdataJsonED\".
如果我更改片段:
[
{
"A": "Y1",
"entries": [
"Z1"
]
},
{
"A": "Y2",
"entries": [
"Z2"
]
}
],
至
[
{
"A": "Y1",
"entries": [
"Z1"
]
},
{
"A": "Y2",
"entries": [
"Z2"
]
"B": true
}
],
那么一切都很好。
这似乎很奇怪,因为我希望能够拥有不一定包含至少一个具有“B”值的元素的列表。事实上,我的 JSON 数据(不是我创建的)有很多。或者,这不是原因,我做了一些愚蠢的事情!
干杯,
解决方案
推荐阅读
- iphone - Crashlytics 和 iPhone XS
- ssl - 如何在 Heroku 上使用 Go 修复 TLS 握手错误?
- r - Plotly GGplot - 情节响应
- android - Android : 谷歌语音流 API
- python - python中hash(str)的时间复杂度
- c++ - Why can't I return a normal map reference with a transparent functor?
- c# - UWP C#如何嵌入服装字体
- android - SearchView AutoComplete 出现黑色边框并覆盖搜索文本?
- javascript - How to verify the mimetype of multiple files from a multer.array function?
- cytoscape.js - Rerender layout on user interaction in Cytoscape