Kotlin DSL for GitHub GraphQL API (GitHub API v4)
Current version: based on the schema 2023-10-07.
With the power of Kotlin DSL, you can effortlessly build queries for the GitHub GraphQL API while ensuring type correctness.
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.lusingander:kraphql-github:v0.0.33'
}
fun main() {
val q = query {
search(query = "kotlin in:name sort:stars", first = 10, type = SearchType.REPOSITORY) {
nodes {
`on Repository` {
name
owner {
login
}
description
stargazerCount
pullRequests(first = 5, orderBy = IssueOrder(field = IssueOrderField.UPDATED_AT, direction = OrderDirection.DESC)) {
nodes {
number
title
updatedAt
}
}
}
}
repositoryCount
}
}
println(q.toString())
// println(q.toEscapedString())
// Output: (it doesn't actually include line breaks)
//
// query {
// search(first: 10, query: "kotlin in:name sort:stars", type: REPOSITORY) {
// nodes {
// ... on Repository {
// name
// owner {
// login
// }
// description
// stargazerCount
// pullRequests(first: 5, orderBy: {direction: DESC, field: UPDATED_AT}) {
// nodes {
// number
// title
// updatedAt
// }
// }
// }
// }
// repositoryCount
// }
// }
}
For more details, see examples.md.
Source codes are generated by lusingander/kraphql.