Skip to content

Instantly share code, notes, and snippets.

@ugurtekbas
Last active October 8, 2023 20:22
Show Gist options
  • Save ugurtekbas/308a9439ec77dddebd585f02dc8af59e to your computer and use it in GitHub Desktop.
Save ugurtekbas/308a9439ec77dddebd585f02dc8af59e to your computer and use it in GitHub Desktop.
Github GraphQL Search Queries
fragment Repo on Repository {
id
name
description
stargazerCount
forkCount
updatedAt
createdAt
url
owner {
login
}
languages(first: 3) {
nodes {
name
color
}
}
}
fragment Page on PageInfo {
startCursor
endCursor
hasNextPage
hasPreviousPage
}
//search phrase could be "searchPhrase": "language:Kotlin forks:>10"
query SearchKotlinRepos($searchPhrase: String!) {
search(
query: $searchPhrase,
type: REPOSITORY,
first: 5
) {
repositoryCount
nodes {
...Repo
}
pageInfo {
...Page
}
}
}
// requesting the next page after "endCursor"
query SearchKotlinReposNextPage($searchPhrase: String!, $endCursor: String) {
search(
query: $searchPhrase,
type: REPOSITORY,
first: 5,
after: $endCursor
) {
repositoryCount
nodes {
...Repo
}
pageInfo {
...Page
}
}
}
// requesting the previous page starting "startCursor"
query SearchKotlinReposPreviousPage($searchPhrase: String!, $startCursor: String) {
search(
query: $searchPhrase,
type: REPOSITORY,
last: 5,
before: $startCursor
) {
repositoryCount
nodes {
...Repo
}
pageInfo {
...Page
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment