skip to Main Content

I’d like to determine when a card has moved from one column to another in a GitHub Project Board using the GitHub GraphQL API.

I can list all issues in a project board (for example, Twitter Bootstrap) using a query like this one:

{
  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
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

There are many types of events in the IssueTimelineConnection, but project-related events are not among them:

...
{
  "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"
        }
      ]
    }
  }
...

I can see when issues have been moved between columns on GitHub’s web page for the issue:

image

I just can’t see these events in the API. Is this a missing feature? Is there another way to get at this information? (Context: I’d like to build a burndown chart for GitHub Project Boards.)

2

Answers


  1. You need to add the Accept header for Project Event Details (https://developer.github.com/v4/previews/#project-event-details) and the Accept header for Issue Preview(https://developer.github.com/v4/previews/#issues-preview)

    Then you can use timelineItems and run a query like this:

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

    This returns:

    {
      "repository": {
        "issue": {
          "timelineItems": {
            "nodes": [
              {
                "__typename": "ConvertedNoteToIssueEvent"
              },
              {
                "__typename": "AssignedEvent"
              },
              {
                "__typename": "LabeledEvent"
              },
              {
                "__typename": "MovedColumnsInProjectEvent"
              }
            ]
          }
        }
      }
    }
    
    Login or Signup to reply.
  2. You can get the column and the last column change date by using the following query for the new projects. This method is not valid for classic projects in GitHub.

    query{
      user(login: "USER_NAME") {
        projectV2(number: 1) {
          title
          items(first: 100) {
            pageInfo {
              endCursor
              hasNextPage
            }
            nodes {
              content {
                ... on Issue {
                  id
                  title
                  url
                  state
                  repository {
                    name
                    owner {
                      login
                    }
                  }
                }
              }
              status: fieldValueByName(name: "Status") {
                ... on ProjectV2ItemFieldSingleSelectValue {
                  column: name
                  updatedAt
                }
              }
            }
          }
        }
      }
    }
    

    The query was tested using GitHub Explorer.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search