Getting Entity IDs
For many fields in the GraphQL API, you will need to provide a unique identifier for the entity you are querying for. This page describes some of the most common identifiers and how to find them.
Workspace IDs
A Workspace is the central entity that houses your team's repositories and issues in Zenhub.
For many fields, you'll need to provide a workspaceId
variable to get the data that pertains to your workspace.
Each workspace ID is a 24-character hexadecimal string, using the GraphQL ID
type, that is
easy to locate in the URL of your team's board. If your board was located at:
https://app.zenhub.com/workspaces/my-team-1894a7c5bbcedd08923ad9f3/board
Then your workspace ID would be 1894a7c5bbcedd08923ad9f3
, and you can use this value as
a variable in your GraphQL queries.
Repository IDs
Both GitHub and Zenhub repositories have their own unique string ID fields (again, using the GraphQL
ID
type) in the GraphQL API. While these aren't easily found in the UI or URL, you can get them from
the GraphQL API with a simple query.
If you already have a workspace ID (see above), the following query will give you the IDs for each repository in the workspace:
query getRepoIds($workspaceId: ID!) {
workspace(id: $workspaceId) {
repositoriesConnection {
nodes {
# This will return the ID of each GitHub repository, alongside their names
id
name
}
}
zenhubRepository {
# Returns the ID of the workspace's Zenhub repository, used for creating Zenhub issues
id
}
}
}
GitHub Issue Numbers
Some fields in the GraphQL API require a GitHub issue number. These are easy to find in the Zenhub and GitHub websites, both in the URL and in the UI.
For a GitHub issue URL, the issue number is the numeric part at the end. In the case of the issue URL https://github.com/facebook/react/issues/31025
, the issue number is 31025
. This would be provided as an Int
variable in the GraphQL API