Get all events for a repository with GraphQL


#1

I am working on making some reports (on enterprise version).

Is it possible to get all the events of a repository?
Note: in REST V3 it is possible using GET /repos/:owner/:repo/issues/events

Additionally, I would like to get all of only certain types of event. For example, I want to get all ‘milestoned’ events OR ‘closed’ events.

If it is not possible in graphQL, then is there a way I could query for only ‘milestoned’ events in REST v3 ?

thank you and regards,
Sambhav


#2

The Events API in the REST API has some notable restrictions:

Events support pagination, however the per_page option is unsupported. The fixed page size is 30 items. Fetching up to ten pages is supported, for a total of 300 events.

Only events created within the past 90 days will be included in timelines. Events older than 90 days will not be included (even if the total number of events in the timeline is less than 300).
https://developer.github.com/v3/activity/events/

As far as I know, it is not possible to filter against certain types of events in the REST API.

In GraphQL there is an issue timeline connection, which looks like it should have what you need.
https://developer.github.com/v4/union/issuetimelineitem/

{
  repository(owner: "sinatra", name: "sinatra") {
    issue(number: 1441) {
      timeline(first: 10) {
        nodes {
          ... on MilestonedEvent {
            actor {
              login
            }
          }
          ... on ClosedEvent {
            actor {
              login
            }
          }
        }
      }
    }
  }
}