GitHub GraphQL API Filter on custom text field in Project V2

GitHub GraphQL API Filter on custom text field in Project V2


5

We are using GitHub Projects (Beta). I created a custom text field called oma-project. I want to use the API to filter on this field, e.g., oma-project: "P0001". This should return all issues with this value in the custom field.

Looking at the Projects (beta) docs, I can list the first n issues but I don’t know how I can pass a filter based on the value of the custom field.

This is as far as I have gotten.

{
  node(id: "nodeid") {
    ... on ProjectV2 {
      items(first: 2) {
        nodes {
          fieldValues(first: 8) {
            nodes {
              ... on ProjectV2ItemFieldTextValue {
                text
                field {
                  ... on ProjectV2FieldCommon {
                    name
                  }
                }
              }
            }
          }
          content {
            ... on Issue {
              id
              title
            }
          }
        }
      }
    }
  }
}

returns:


{
  "data": {
    "node": {
      "items": {
        "nodes": [
          {
            "fieldValues": {
              "nodes": [
                {},
                {},
                {},
                {
                  "text": "Retrieve Notes via OData",
                  "field": {
                    "name": "Title"
                  }
                },
                {},
                {
                  "text": "P9999",
                  "field": {
                    "name": "OMA Project"
                  }
                }
              ]
            },
            "content": {
              "id": "I_kwDOFT-pvM5AZNLm",
              "title": "Retrieve Notes via OData"
            }
          },
          {
            "fieldValues": {
              "nodes": [
                {},
                {},
                {
                  "text": "Capex Approval Type",
                  "field": {
                    "name": "Title"
                  }
                },
                {},
                {},
                {
                  "text": "P0708",
                  "field": {
                    "name": "OMA Project"
                  }
                }
              ]
            },
            "content": {
              "id": "I_kwDOFT-pvM5K85HZ",
              "title": "Capex Approval Type"
            }
          }
        ]
      }
    }
  }
}

2 Answers
2


1

I’m having the same issue when working on a GitHub action to move a list of items from a status to another status, and it seems currently the API doesn’t support ProjectV2 item filtering.

My current workaround is to query all the items from the project and then later filter out the results using jq or JavaScript


0

after doing some research i have to conclude that the graphQL API still doesn’t support this.

(leaving this comment so people know if it worth to research or not)



Leave a Reply

Your email address will not be published. Required fields are marked *