graphql - 如何通过没有边的后代过滤 GraphQL 结果?
问题描述
我刚开始研究 GraphQL,我想知道是否有一种方法可以过滤没有任何节点的结果。这是一个相对简单的示例查询:
query {
organization(login:"GitHub") {
repositories(first: 20) {
edges {
node {
name
pullRequests(first: 5, states: OPEN){
edges {
node {
title
author{
login
}
updatedAt
}
}
}
}
}
}
}
}
这是查询返回的结果的子集:
{
"data": {
"organization": {
"repositories": {
"edges": [
{
"node": {
"name": "gitignore",
"pullRequests": {
"edges": [
{
"node": {
"title": "Create new CodeComposerStudio.gitignore",
"author": {
"login": "wolf99"
},
"updatedAt": "2017-07-26T20:31:53Z"
}
},
{
"node": {
"title": "Create PVS.gitignore",
"author": {
"login": "cesaramh"
},
"updatedAt": "2017-05-01T19:42:07Z"
}
},
{
"node": {
"title": "gitignore for Magic Software Enterprises product xpa ",
"author": {
"login": "tommes"
},
"updatedAt": "2017-05-01T19:41:53Z"
}
},
{
"node": {
"title": "Create PSoC.gitignore",
"author": {
"login": "dbrwn"
},
"updatedAt": "2017-05-01T19:41:39Z"
}
},
{
"node": {
"title": "add ThinkPHP gitignore file",
"author": {
"login": "swumao"
},
"updatedAt": "2017-05-01T19:40:53Z"
}
}
]
}
}
},
{
"node": {
"name": "dmca",
"pullRequests": {
"edges": []
}
}
}
]
}
}
}
}
所以我想知道是否有办法修改我的查询,这样它就不会返回名为的节点,dmca
因为pullRequests
.
解决方案
如果您使用的是 githubs graphql api,那么似乎没有办法过滤这些边,但是如果您正在实现 graphql 服务器,那么就有可能知道边节点是什么,从而在边解析器中过滤它
推荐阅读
- python - tkinter 关闭两个弹出窗口
- python - 如何获取在 QWebEngineView 中加载的页面的 html
- javascript - How to fix text encoding errors in title and description from Youtube Api v3?
- html - 包装容器中相邻的 div 的 CSS 高度问题
- jquery - 在之前旋转时旋转“Y”方向的元素
- html - 如何修复单页锚点
- firebase-cloud-messaging - java.lang.NoSuchMethodError: com.google.firebase.FirebaseOptions.getConnectTimeout()I
- angular - 在角度上显示弹出窗口的麻烦
- vb.net - 子字符串与字符串不匹配
- python - 在打开的 cv 中接收 NDI 视频流