Working and filtering project cards with GraphQL


#1

Greetings GitHubbers!

I’m trying to figure out how to perform the following tasks with GraphQL:

  • find a card corresponding to an issue within a project
  • find any closed cards within a project not under the column named “Done”.

I’m having trouble querying project card issues where the state is closed is true. I have gotten as far as the example below, but am having a lot of trouble filtering issues within the ... on Issue clause. Is what I’m trying to do even possible?

Thanks!
-Roberto

query {
  organization(login:"org") {
    project(number:1) {
      columns(first:100){
        nodes{
          id,
          name,
          cards(first:1){
            nodes{
              id,
              url,
              content {
                ... on Issue {
                  url,
                  closed
                }
              }
            }
          }
        }
      }
    }
  }
}

#2

Hey @rca!

I’ll tackle your two tasks in separate queries:

  1. Find a card corresponding to an issue within a project

I’m assuming you’re working in a specific repository:

query{
  repository(owner:"owner", name:"name"){
    issues(last: 5){
      nodes{
        projectCards(first: 10){
          nodes{
            content
            id
            state
            url
          }
        }
      }
    }
  }
}
  1. Find any closed cards under a project not under the “Done” column

Unfortunately we don’t currently have column filtering or card state filtering in the API. For now, you’ll simply have to grab all columns and all cards, and do some filtering on your end. I’ve added this to our list of schema requests to tackle, I’ll be sure to give you a heads up here when we have more news :slight_smile: