Need help navigating new GraphQL API

I am very new to GraphQL in general, and ZenHub GraphQL specifically.

What I would like to do is automate the process of gathering information about given sprint:

  1. Get list of all sprints (so that I can refer to them in the subsequent query)
  2. For the last spring, get the list of all issues assigned to the sprint.
  3. For each of the issues, get the name and labels assigned to that issue.

Can someone point me out to the documentation of the corresponding endpoints, or guide towards a pathway how I could discover how to use the endpoints I need to complete the above?

This would be HUGE help. Right now I am navigating in the dark having to take a lot of guesses.

Is it unreasonable to expect some documentation, now that the public API was announced nearly a month ago? Or is it expected that GraphQL is expected to be discovered via API?

I think I found a query that is supposed to ask for documentation, but the description returned is blank.

query  = """{
  __type(name: "Sprint") {
    name
    description
  }
}"""

returns

{
  "data": {
    "__type": {
      "name": "Sprint",
      "description": null
    }
  }
}

Hey Fedorov,

Here is the introspection query you can run to see the entire schema. Hopefully this helps and provides a starting point for you.

query IntrospectionQuery {
  __schema {                                     
    queryType { name }                           
    mutationType { name }                        
    subscriptionType { name }                    
    types {                                      
      ...FullType                                
    }                                            
    directives {                                 
      name                                       
      description                                
      locations                                  
      args {                                     
        ...InputValue                            
      }                                          
    }
  }
}
fragment FullType on __Type {
  kind
  name
  description
  fields(includeDeprecated: true) {
    name
    description
    args {
      ...InputValue
    }
    type {
      ...TypeRef
    }
    isDeprecated
    deprecationReason
  }
  inputFields {
    ...InputValue
  }
  interfaces {
    ...TypeRef
  }
  enumValues(includeDeprecated: true) {
    name
    description
    isDeprecated
    deprecationReason
  }
  possibleTypes {
    ...TypeRef
  }
}
fragment InputValue on __InputValue {
  name
  description
  type { ...TypeRef }
  defaultValue
  
  
}
fragment TypeRef on __Type {
  kind
  name
  ofType {
    kind
    name
    ofType {
      kind
      name
      ofType {
        kind
        name
        ofType {
          kind
          name
          ofType {
            kind
            name
            ofType {
              kind
              name
              ofType {
                kind
                name
              }
            }
          }
        }
      }
    }
  }
}```

Not really. At this point in time, this is waaaay over my head, and I am actually not able to run the query as is (“Unexpected end of document”). I am not sure if I am supposed to do something first to modify it, or there is a typo, or something else.

Below is the result of visualizing the returned value of that query using this tool: http://nathanrandal.com/graphql-visualizer/. (No, I was not able to figure out how to make that figure readable).

If a query returns node type, and __typename value on that is Sprint, is there a way to access the fields of Sprint for that node? Since if I request fields of Sprint for that node, I get “field does not exist” error.

Hey Fedorov,

Here are a couple queries that hopefully will help you get the data you are looking for

List of All Sprints in a Workspace

query {
  workspace(id: "WORKSPACE_ID"){
    sprints{
      totalCount
      nodes {
        id
        name
        completedPoints
        closedIssuesCount
        state
        startAt
        endAt
      }
    }
  }
}

List of Issues in the last Sprint with Name and Labels

query {
  workspace(id: "WORKSPACE_ID"){
    sprints(last: 1, filters:{state: {eq: CLOSED}}) {
      nodes {
        id
        name
       	issues {
          nodes {
            title
            labels {
              nodes {
                name
              }
            }
          }
        }
      }
    }
  }
}
1 Like

This is super helpful, thank you @Joseph.from.Zenhub!

1 Like