GraphQL Filtering Pull Request on CreatedDate

This query is working, but i am not able to find out how to filter it on Created Date. I want Pull Requests which are created today. 

query GetPullRequest {
 viewer {
  name
    organization(login: “MyOrgName”) {
     name
           repository(name: “My Repo Name”) {
           name
           pullRequests(last: 10, states: OPEN ) {
           nodes {
                   state
                   title
                   permalink
                   createdAt
                  author {
                           login
                           avatarUrl
                 }
             }
          }
       }
}
}

To my understanding, if the PullRequestsConnection doesn’t have a method of filtering by date, then it can’t be done via that type of query. However, you could use the search query like this:

{
  search(query: "repo:atom/atom is:pr is:open created:>2019-04-01", type: ISSUE, last: 100) {
    edges {
      node {
        ... on PullRequest {
          url
          title
          createdAt
        }
      }
    }
  }
}

Just replace 2019-04-01 with today’s date.

4 Likes

Thanks a lot @lee-dohm , where can i find more on the ‘search’, ‘query’ grammer. Any pointer will be appriciated.  I want to skip pr where author.login is equal to ‘greenkeeper’ etc.

It’s the same query syntax as all of GitHub, so you can find the documentation in our help docs on search. So if you wanted to exclude greenkeeper, you could add -author:app/greenkeeper to your search query.

I hope that helps!

2 Likes