API - Get the epic an issue is assigned to

Hi,

I’m doing some work for a team whereby they need all issue data pulled from a Zenhub board and loaded into a csv or spreadsheet for further analysis. Stuff like issue title, issue state, issue labels, etc. But they also want to list the epic name assigned to each individual issue.
I have used the REST API extensively in the past but mostly for adding new issues (Github API) and assigning the new issues to epics. However, I can find absolutely no epic data when I pull an issue with the Zenhub REST API. I can only find pipeline info. Also, when I go the other direction and try to list issues assigned to an epic with the Zenhub REST API - I can find no data related to assigned issues.
Also, being willing to learn the GraphQL API, I tried to find information about how you can pull epic data from an issue or issues data from an epic using GraphQL - but could find nothing outside of what is listed here:

It would seems like a fairly basic requirement of the API to be able to match issues to epics or epics to issues, but I just cant seem to work it out.

Any help or guidance appreciated.

Hi,

@donal-keane, I face the same issue. I’d like to know if an issue belongs to an epic. As I couldn’t fetch such data using REST API, I found a workaround using GraphQL. Please, take a look at the following query:

query getIssueInfo($repositoryGhId: Int!, $issueNumber: Int!) {
  issueByInfo(repositoryGhId: $repositoryGhId, issueNumber: $issueNumber) {
    id
    number
    title
    parentZenhubEpics(first: 10) {
      nodes {
        oldIssue {
           title
          id
          ghId
        }
      }
    }
    parentEpics(first: 1) {
      nodes {
        issue {
          title
          id
          ghId
          number
          repository {
            ghId
          }
        }
        __typename
      }
    }
    __typename
  }
}

The such query returns an issue details and its epic issues. Unfortunately, the query contains two weird things:

  1. parentEpics() is marked as deprecated (This field must not be used. Use parentZenhubEpics).
  2. parentZenhubEpics() always returns an empty array.

So, the query uses deprecated things that may stop working.

I hope it helps.

Hi @pomek - thanks very much for your detailed response. I will attempt to give this a go and see how it works out! Much appreciated!