我刚刚开始学习 graphql,并创建了一个查询,该查询返回前 10 个已关闭问题的列表以及一些属性。令我惊讶的是,我得到的 JSON 中的响应对象有时是空的,有时它们是非空的。响应是随机的。我也用邮递员测试过。由于我使用 jackson 将 json 响应映射到 Java 类并执行一些操作,因此在处理空对象时会引发异常。
1)基本上,我想要一个非空对象的已关闭问题。查询中有什么问题吗?如果是,有人可以说出正确的查询吗?
2)另外,我想知道返回空节点对象背后的逻辑
使用的查询
{
search(first: 20, type: ISSUE, query: "created:<2019-09-21 state:closed") {
issueCount
edges {
node {
... on Issue {
createdAt
closedAt
title
url
repository {
name
}
}
}
}
}
}
回应 1
{
"data": {
"search": {
"issueCount": 92339271,
"edges": [
{
"node": {
"createdAt": "2019-09-20T23:59:57Z",
"closedAt": "2019-09-21T19:59:32Z",
"title": "MJPEG stream won't open",
"url": "https://github.com/mpv-player/mpv/issues/6964",
"repository": {
"name": "mpv"
}
}
},
{
"node": {
"createdAt": "2019-09-20T23:59:50Z",
"closedAt": "2019-09-21T01:19:39Z",
"title": "Upgrade from v0.5.0 to v0.6.0 with attached volume failed",
"url": "https://github.com/longhorn/longhorn/issues/745",
"repository": {
"name": "longhorn"
}
}
},
{
"node": {}
},
{
"node": {}
},
{
"node": {}
},
{
"node": {}
},
{
"node": {
"createdAt": "2019-09-20T23:58:52Z",
"closedAt": "2019-09-21T01:55:15Z",
"title": "bad linkage",
"url": "https://github.com/signalapp/Signal-Desktop/issues/3608",
"repository": {
"name": "Signal-Desktop"
}
}
},
{
"node": {}
},
{
"node": {
"createdAt": "2019-09-20T23:58:36Z",
"closedAt": "2019-09-21T00:57:54Z",
"title": "Breaks Some Links on Firefox for Mac",
"url": "https://github.com/duckduckgo/duckduckgo-privacy-extension/issues/416",
"repository": {
"name": "duckduckgo-privacy-extension"
}
}
},
{
"node": {}
},
{
"node": {}
},
{
"node": {}
},
{
"node": {}
},
{
"node": {}
},
{
"node": {}
},
{
"node": {}
},
{
"node": {}
},
{
"node": {
"createdAt": "2019-09-20T23:56:11Z",
"closedAt": "2019-09-23T18:43:30Z",
"title": "ci: upload coverage reports from GitHub Actions",
"url": "https://github.com/hyperledger/aries-framework-go/issues/314",
"repository": {
"name": "aries-framework-go"
}
}
},
{
"node": {}
},
{
"node": {
"createdAt": "2019-09-20T23:56:07Z",
"closedAt": "2019-09-21T02:53:35Z",
"title": "0xxx.ws",
"url": "https://github.com/NanoMeow/QuickReports/issues/1885",
"repository": {
"name": "QuickReports"
}
}
}
]
}
}
}
回应 2
{
"data": {
"search": {
"issueCount": 92339271,
"edges": [
{
"node": {}
},
{
"node": {}
},
{
"node": {}
},
{
"node": {}
},
{
"node": {}
},
{
"node": {}
},
{
"node": {}
},
{
"node": {}
},
{
"node": {}
},
{
"node": {}
},
{
"node": {}
},
{
"node": {}
},
{
"node": {}
},
{
"node": {
"createdAt": "2019-09-20T23:58:36Z",
"closedAt": "2019-09-21T00:57:54Z",
"title": "Breaks Some Links on Firefox for Mac",
"url": "https://github.com/duckduckgo/duckduckgo-privacy-extension/issues/416",
"repository": {
"name": "duckduckgo-privacy-extension"
}
}
},
{
"node": {}
},
{
"node": {}
},
{
"node": {}
},
{
"node": {}
},
{
"node": {}
},
{
"node": {}
}
]
}
}
}