我们正在使用 GitHub 项目(测试版)。我创建了一个名为 oma-project
的自定义文本字段。我想使用 API 来过滤此字段,例如 oma-project: "P0001"
。这应该会在自定义字段中返回所有与此值有关的问题。
查看 Projects (beta) docs ,我可以列出前 n 个问题,但我不知道如何根据自定义字段的值传递过滤器。
这是我所了解的。
{
node(id: "nodeid") {
... on ProjectV2 {
items(first: 2) {
nodes {
fieldValues(first: 8) {
nodes {
... on ProjectV2ItemFieldTextValue {
text
field {
... on ProjectV2FieldCommon {
name
}
}
}
}
}
content {
... on Issue {
id
title
}
}
}
}
}
}
}
返回:
{
"data": {
"node": {
"items": {
"nodes": [
{
"fieldValues": {
"nodes": [
{},
{},
{},
{
"text": "Retrieve Notes via OData",
"field": {
"name": "Title"
}
},
{},
{
"text": "P9999",
"field": {
"name": "OMA Project"
}
}
]
},
"content": {
"id": "I_kwDOFT-pvM5AZNLm",
"title": "Retrieve Notes via OData"
}
},
{
"fieldValues": {
"nodes": [
{},
{},
{
"text": "Capex Approval Type",
"field": {
"name": "Title"
}
},
{},
{},
{
"text": "P0708",
"field": {
"name": "OMA Project"
}
}
]
},
"content": {
"id": "I_kwDOFT-pvM5K85HZ",
"title": "Capex Approval Type"
}
}
]
}
}
}
}
最佳答案
我在处理将项目列表从一个状态移动到另一个状态的 GitHub 操作时遇到了同样的问题,目前看来 API 不支持 ProjectV2 项目过滤。
我目前的解决方法是查询项目中的所有项目,然后使用 jq 筛选出结果或JavaScript
关于GitHub GraphQL API Filter on Project V2 中的自定义文本字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73103486/