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

Q: How do I make an advanced Filter Search using GraphQL and GitHub i.e. watchers > x?

am trying to use GraphQL to find interesting repositories on Github. Filtering for stars, forks and size was possible. However I cannot filter my search results for number of watches or number of releases or number of dependent repositories.

 

Does anybody have an idea how do query that?

 

query {
  search(
    type:REPOSITORY, 
    query: """
      stars:<1000
      forks:>10
      size:>2000
      pushed:>=2019-08-01
      created:>=2018-08-01

    """,
    last: 100
  ) {
    repos: edges {
      repo: node {
        ... on Repository {
          name
          description
          url
          owner{__typename}
          licenseInfo{name}
          watchers{watchers: totalCount}
          releases {releases: totalCount}
          forks: forkCount
          pullRequests {pullRequests: totalCount}
          stargazers {stars: totalCount}
          openIssues: issues(states:OPEN){totalCount}
          totalIssues: issues {totalIssues: totalCount}
          primaryLanguage {primaryLanguage: name}
          languages(first: 3) { nodes {name} }
          repositoryTopics(first: 3) {nodes {topic {name}}}
          createdAt
          pushedAt
          updatedAt

       }
      }
    }
  }
}
2 Replies
Community Manager
Message 2 of 3

Re: Q: How do I make an advanced Filter Search using GraphQL and GitHub i.e. watchers > x?

GraphQL doesn't support filtering or ordering in the query language itself. The API has to provide those features and if they're not provided, then one has to do the filtering or ordering after receiving the data on the client side. So if the API doesn't provide the filtering you're looking for, then you'll have to filter the data after you download it.

 

I hope that helps.

Copilot Lvl 3
Message 3 of 3

Re: Q: How do I make an advanced Filter Search using GraphQL and GitHub i.e. watchers > x?

Thank you that helped me a lot!