如何使用GitHub GraphQL API查看项目中列之间的问题?

问题描述 投票:0回答:1

我想确定一张卡使用GitHub GraphQL API在GitHub Project Board中从一列移动到另一列的时间。

我可以使用类似这样的查询列出项目板中的所有问题(例如,Twitter Bootstrap):

{
  organization(login: "twbs") {
    repository(name: "bootstrap") {
      project(number: 4) {
        columns(first: 5) {
          nodes {
            name
            cards(first: 10) {
              nodes {
                content {
                  __typename
                  ... on Issue {
                    title
                    url
                    timeline(first: 10) {
                      nodes {
                        __typename
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

many types of eventsIssueTimelineConnection,但项目相关事件不在其中:

...
{
  "content": {
    "__typename": "Issue",
    "title": "Remove inner white border effect on popovers",
    "url": "https://github.com/twbs/bootstrap/issues/23763",
    "timeline": {
      "nodes": [
        {
          "__typename": "RenamedTitleEvent"
        },
        {
          "__typename": "IssueComment"
        },
        {
          "__typename": "LabeledEvent"
        },
        {
          "__typename": "LabeledEvent"
        },
        {
          "__typename": "IssueComment"
        },
        {
          "__typename": "CrossReferencedEvent"
        },
        {
          "__typename": "CrossReferencedEvent"
        },
        {
          "__typename": "LabeledEvent"
        },
        {
          "__typename": "ClosedEvent"
        },
        {
          "__typename": "CrossReferencedEvent"
        }
      ]
    }
  }
...

我可以看到GitHub网页上的列之间的问题何时发生了问题:

我只是在API中看不到这些事件。这是一个缺少的功能吗?有没有其他方法来获取此信息? (背景:我想建立一个burndown chart for GitHub Project Boards。)

github graphql github-api github-graphql github-projects
1个回答
0
投票

您需要为项目事件详细信息(https://developer.github.com/v4/previews/#project-event-details)添加Accept标头,并为问题预览添加Accept标头(https://developer.github.com/v4/previews/#issues-preview

然后你可以使用timelineItems并运行这样的查询:

query {
  repository(owner: "buildo", name: "react-components") {
    issue(number: 1321) {
      timelineItems(first: 10) {
        nodes {
          __typename
        }
      }
    }
  }
}

返回:

{
  "repository": {
    "issue": {
      "timelineItems": {
        "nodes": [
          {
            "__typename": "ConvertedNoteToIssueEvent"
          },
          {
            "__typename": "AssignedEvent"
          },
          {
            "__typename": "LabeledEvent"
          },
          {
            "__typename": "MovedColumnsInProjectEvent"
          }
        ]
      }
    }
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.