Get the assigned and closed dates of an issue


#1

:wave: Hello,

I’m building an internal reporting tool for our dev team, for which I need to fetch the latest closed_at and assigned_at date for an issue. Until now I used the v3 events API but I needed to fetch all the events of the issue to get the “assigned” event. Graphql caught my interest here as I thought I could design a query just for those “assigned” / “closed” event.

I’ve seen the doc for the AssignedEvent and ClosedEvent but I’m struggling to use them in a query.

Would you please provide an example of query using those objects please ?

Here is the closest from my objective that I’ve reached so far : This query gives me the results but I still need to fetch a lot of events I don’t care (timeline(last: 100)). It’s feels like a broken approach : I would like to filter the events on event type.

{
  repository(owner: "octocat", name: "Hello-World") {
    issue(number: 162) {
      title
      author {
        login
      }
      assignees(last: 1) {
        edges {
          node {
            login
          }
        }
      }
      createdAt
      closed
      timeline(last: 100) {
        edges {
          node {
            __typename
            ... on ClosedEvent {
              createdAt
            }
            ... on AssignedEvent {
              createdAt
              user {
                login
              }
            }
          }
        }
      }
    }
  }
}

#3

Hi @edelans!

Unfortunately, I think you’ll have the same problem in the GraphQL API as you will in the REST API - there is currently no ability to filter on the events/timeline connection to only get a subset of events, you’ll have to fetch them all and then look for what you need.

If you’re interested in the ability to filter, I am happy to enter it in as a schema request? I think you’re probably not the only person that would like to do something like this :smile:


#4

Hi @nickvanw, thanks for your reply and your suggestion. Indeed, I’ll appreciate this schema request a lot !