Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 2

GraphQL - Get all commits by all users in all orgs with filtered date

Solved! Go to Solution.

Hi,

 

  I have the following query which returns all the commit history for the given org. 

 

Questions 1:-

 

1. Not sure, How to filter commits history by date

2. Here, I pass orgName. How to get across all orgs?

 

{
search(query: "org:test", type: REPOSITORY, last: 100) {
edges {
node {
... on Repository {
name
defaultBranchRef {
name
target {
... on Commit {
history(first: 100) {
edges {
node {
... on Commit {
committedDate
additions
author {
name
email
}
}
}
}
}
}
}
}
}
}
}
}
}
1 Reply
Highlighted
Solution
Community Manager
Message 2 of 2

Re: GraphQL - Get all commits by all users in all orgs with filtered date

You can filter commit history by date using the `since` or `until` parameter to the `history` connection on `Commit`:

 

{
  search(query: "org:test", type: REPOSITORY, last: 100) {
    nodes {
      ... on Repository {
        name
        defaultBranchRef {
          name
          target {
            ... on Commit {
              history(first: 100, since: "2013-07-11T00:00:00") {
                totalCount
                nodes {
                  ... on Commit {
                    committedDate
                    additions
                    author {
                      name
                      email
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

As for getting all orgs, there isn't currently a way to do that via the GraphQL API because the `search` connection requires something in the search query. There's also no top-level connection that allows you to list all users, orgs, or repositories.

 

I hope that helps!