3

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.)

danvk
  • 15,863
  • 5
  • 72
  • 116
  • 1
    There is a mysterious `MovedColumnsInProjectEvent` but [it's an orphan](https://platform.github.community/t/how-can-movedcolumnsinprojectevent-events-be-queried/3396?u=danvk). – danvk Jul 11 '18 at 22:09
  • 1
    … and evidently [not very useful](https://platform.github.community/t/how-can-movedcolumnsinprojectevent-events-be-queried/3396/5?u=danvk). – danvk Jul 11 '18 at 22:16
  • Hi @danvk did you ever find a solution for this? The github community link is dead, I have pretty much the exact same use case, simply knowing that there _was_ a MovedColumnsInProjectEvent isnt really helpful. Is there a way to actually get this [MovedColumnsInProjectEvent](https://developer.github.com/v4/object/movedcolumnsinprojectevent/#implements) object? – bradimus Jul 10 '19 at 21:18

2 Answers2

1

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. The updatedAt field will give the update last column change date.

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.

0

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"
          }
        ]
      }
    }
  }
}
user1345108
  • 230
  • 2
  • 15