用一个例子让大家很容易理解,https://developer.github.com/v4/explorer/ https://developer.github.com/v4/explorer/
查询观众信息:
query {
viewer {
followers {
totalCount
}
following {
totalCount
}
}
}
结果是:
{
"data": {
"viewer": {
"followers": {
"totalCount": 131
},
"following": {
"totalCount": 28
}
}
}
}
我想要的是:
{
"data": {
"viewer": {
"followersCount" 131,
"followingCount": 28
}
}
}
那么 GraphQL 支持这个吗?以及如何做?
GraphQL 不支持这种类型的数据扁平化。
您必须更改代码中的数据结构或使用返回的数据结构。
EDIT:我刚刚遇到这个存储库(graphql-lodash) https://github.com/APIs-guru/graphql-lodash这可以帮助您实现您想要的目标。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)