Will Stone
Will Stone

Reputation: 4815

Using GitHub API v4 GraphQL to find all open issues belonging to repositories owned by the user

Can someone please point me in the right direction for listing all open issues that are in repos owned by the user? Thanks in advance.

Upvotes: 10

Views: 5416

Answers (2)

bswinnerton
bswinnerton

Reputation: 4721

Your answer is probably the most efficient way in terms of pagination, but another approach you could take is to iterate over all of the user's owned repositories, and for each of those repositories fetch their issues with something like:

query($userLogin: String!) {
  user(login: $userLogin) {
    repositories(affiliations: [OWNER], last: 10) {
      edges {
        node {
          issues(states: [OPEN], last: 10) {
            edges {
              node {
                createdAt
                title
                url
                repository {
                  name
                }
              }
            }
          }
        }
      }
    }
  }
}

Upvotes: 4

Will Stone
Will Stone

Reputation: 4815

I think I've figured it out. Please let me know if there's a more optimal answer.

query {
  search(first: 100, type: ISSUE, query: "user:will-stone state:open") {
    issueCount
    pageInfo {
      hasNextPage
      endCursor
    }
    edges {
      node {
        ... on Issue {
          createdAt
          title
          url,
          repository {
            name
          }
        }
      }
    }
  }
}

Upvotes: 10

Related Questions