Filter Commit by id/oid


#1

Is there a way to filter Commit by id/oid using GraphQL ?

Here is my query :

{
  repository(name: "rails", owner: "rails") {
    pullRequests(first: 100) {
      edges {
        node {
          commits(first: 100) {
            edges {
              node {
                id
                oid
                message
                author {
                  name
                  email
                  date
                }
              }
            }
          }
        }
      }
    }
  }
}

I would like to filter commits of a Pull request for a specic id or oid. Can this be done in GraphQL query ?

Thanks a lot


#2

Hi! It’s not possible at present, but, I’ve added your issue to our issue tracker to traige for the future.

Out of curiosity, would you expect this to be a new argument on the commits connection, or something else?


#3

Thanks for your reply, a sha filter on CommitConnection would be great

For instance :

{
  repository(name: "rails", owner: "rails") {
    pullRequests(first: 100) {
      edges {
        node {
          commits(first: 100, sha: "367a56117123e977959fa4823d7c5b0fea5945b2") {
            edges {
              node {
                id
                oid
                message
                committedDate
                author {
                  name
                  email
                  date
                }
              }
            }
          }
        }
      }
    }
  }
}

Looking at Github commit API, it would be great to have the same filters :

  • sha : (string) SHA or branch to start listing commits from. Default: the repository’s default branch (usually master).
  • path : (string) Only commits containing this file path will be returned.
  • author : (string) GitHub login or email address by which to filter by commit author.
  • since : (string) Only commits after this date will be returned. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
  • until : (string) Only commits before this date will be returned. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.

Thanks a lot


#4

Any progress on this issue? is there a workaround for it? or just use the REST API for now?


#5

Managed to make it work using this query:

query {
  repository(owner: "OWNER", name: "NAME") {
    object(oid: "COMMIT_ID_HERE") {
      ... on Commit {
        id
        oid
      }
    }
  }
}