lusingander / kraphql-github

Kotlin DSL for GitHub GraphQL API (GitHub API v4)

Home Page:https://jitpack.io/#lusingander/kraphql-github

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

kraphql-github

Release

Kotlin DSL for GitHub GraphQL API (GitHub API v4)

Current version: based on the schema 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

Installation

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

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

Usage

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.

Related projects

Source codes are generated by lusingander/kraphql.

About

Kotlin DSL for GitHub GraphQL API (GitHub API v4)

https://jitpack.io/#lusingander/kraphql-github

License:MIT License


Languages

Language:Kotlin 100.0%