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

GraphQL Filtering Pull Request on CreatedDate

Solved! Go to Solution.

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
                 }
             }
          }
       }
}
}

3 Replies
Solution
Community Manager
Message 2 of 4

Re: GraphQL Filtering Pull Request on CreatedDate

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.

Copilot Lvl 3
Message 3 of 4

Re: GraphQL Filtering Pull Request on CreatedDate

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.

Community Manager
Message 4 of 4

Re: GraphQL Filtering Pull Request on CreatedDate

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!