Raja Rao
Raja Rao

Reputation: 5865

Filter Github issues by author using their graphql API

I'm trying to figure out how to get the list of issues by author. I can get the list of issues but I don't know is how to filter 'by author'.

The following returns a list of issues from the repo "Hello-World" of the owner "octocat". What I want to do is to filter issue author: "yosuke-furukawa" or any other author. How to do that? You may try it out at the explorer.

  repository(owner:"octocat", name:"Hello-World") {
    issues(last:20, states:CLOSED) {
      edges {
        node {
          bodyText
          author{
            login
          }
        }
      }
    }
  }
}

Upvotes: 2

Views: 1303

Answers (1)

Igor Akkerman
Igor Akkerman

Reputation: 2478

To get the list of issues created by a specific author, you can query for objects of type ISSUE, adding the repository information and the author name in the query string:

query {
  search(
    type: ISSUE,
    query: """
      repo:octocat/Hello-World 
      author:yosuke-furukawa
      state:closed
    """,
    last: 20
  ) {
    edges {
      node {
        ... on Issue {
          id
          title
          bodyText
          author {
            login
          }
        }
      }
    }
  }
}

The full syntax for querying issues can be found here: https://help.github.com/en/articles/searching-issues-and-pull-requests

Upvotes: 1

Related Questions