GraphQL repo issues has no `closedBy` field

While running queries against repository issues I cannot find a field for events that includes a closedBy attribute (https://developer.github.com/v4/object/closedevent/).

1 Like

Hey @reka18,

Thanks for being here! The Actor field should show this. Are you able to post a sample of your results? If needed to be private please contact us at https://github.com/contact and we’ll take a look.

query {
  viewer {
    repository(name: "<name-of-repo-here"){
      issues(states: CLOSED, first:10){
        edges{
          node{
            boody
          }
        }
      }
    }
  }
}

When I press the CTRL + SPACE to see available options, I cannot see the actor field.

I think what @reka18 meant was that the Issue Object doesn’t have a ClosedEvent field which actually has the Actor field with the user details.

The v3 API has a closed_by field present.

I ended up contacting Github support and they provided a solution:

Have you tried using the timelineItems connection, using an approach similar to this:

https://github.community/t5/GitHub-API-Development-and/Filtering-on-v4-GraphQL-issue-sub-nodes/m-p/20933/highlight/true#M1221

There’s a CLOSED_EVENT that’s available through that:

https://developer.github.com/v4/enum/issuetimelineitemsitemtype/#issuetimelineitemsitemtype

So the query becomes something like:

query commits{
  repository(owner: "rohit-smpx", name:"inno"){
    issues(first: 10, states:CLOSED){
      nodes{
        number
        title
        timelineItems(itemTypes:CLOSED_EVENT, last: 1){
          nodes{
            __typename
            ...on ClosedEvent{
              actor{
                login
              }
              createdAt
            }
          }
        }
      }
    }
  }
}

Thanks Ivan for the response.

1 Like