An open API service indexing awesome lists of open source software.

https://github.com/lusingander/kraphql-github

Kotlin DSL for GitHub GraphQL API (GitHub API v4)
https://github.com/lusingander/kraphql-github

github github-api-v4 graphql kotlin kotlin-dsl

Last synced: 11 months ago
JSON representation

Kotlin DSL for GitHub GraphQL API (GitHub API v4)

Awesome Lists containing this project

README

          

kraphql-github
====

[![Release](https://jitpack.io/v/lusingander/kraphql-github.svg)](https://jitpack.io/#lusingander/kraphql-github)

Kotlin DSL for [GitHub GraphQL API (GitHub API v4)](https://docs.github.com/en/free-pro-team@latest/graphql)

Current version: based on the [schema 2023-10-07](https://docs.github.com/en/free-pro-team@latest/graphql/overview/changelog#schema-changes-for-2023-10-07).

## About

With the power of Kotlin DSL, you can effortlessly build queries for the GitHub GraphQL API while ensuring type correctness.

![image](./image.gif)

## Installation

```groovy
repositories {
maven { url 'https://jitpack.io' }
}

dependencies {
implementation 'com.github.lusingander:kraphql-github:v0.0.33'
}
```

## Usage

```kotlin
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](./examples.md).

## Related projects

Source codes are generated by [lusingander/kraphql](https://github.com/lusingander/kraphql).