{"id":20548103,"url":"https://github.com/lusingander/kraphql","last_synced_at":"2025-04-14T10:50:36.608Z","repository":{"id":105969031,"uuid":"300841459","full_name":"lusingander/kraphql","owner":"lusingander","description":"Generate Kotlin DSL from GraphQL schema","archived":false,"fork":false,"pushed_at":"2022-02-19T10:08:20.000Z","size":1702,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-11T11:38:41.220Z","etag":null,"topics":["code-generation","dsl","gradle-plugin","graphql","kotlin","kotlin-dsl"],"latest_commit_sha":null,"homepage":"https://plugins.gradle.org/plugin/com.github.lusingander.kraphql-plugin","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lusingander.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-03T09:17:34.000Z","updated_at":"2023-11-20T07:46:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"89c6fb35-355d-4ac2-9d4d-d31f861d6fb6","html_url":"https://github.com/lusingander/kraphql","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lusingander%2Fkraphql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lusingander%2Fkraphql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lusingander%2Fkraphql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lusingander%2Fkraphql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lusingander","download_url":"https://codeload.github.com/lusingander/kraphql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248868826,"owners_count":21174754,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-generation","dsl","gradle-plugin","graphql","kotlin","kotlin-dsl"],"created_at":"2024-11-16T02:12:11.592Z","updated_at":"2025-04-14T10:50:36.601Z","avatar_url":"https://github.com/lusingander.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"KraphQL\n====\n\n[![gradle plugin](https://img.shields.io/maven-metadata/v/https/plugins.gradle.org/m2/com/github/lusingander/kraphql-plugin/com.github.lusingander.kraphql-plugin.gradle.plugin/maven-metadata.xml.svg?label=Gradle\u0026style=flat-square)](https://plugins.gradle.org/plugin/com.github.lusingander.kraphql-plugin)\n\nKotlin DSL Generator for GraphQL\n\n```\n[GraphQL schema] --(KraphQL)--\u003e [DSL definition .kt file] \u003c-- Call from your code\n```\n\n\u003cimg src=\"./image.gif\" width=600\u003e\n\n## About\n\nFor example, given the following schema:\n\n```graphql\ntype Query {\n    books: [Book!]!\n    authors: [Author!]!\n}\n\ntype Book {\n    title: String!\n    author: Author!\n}\n\ntype Author {\n    firstName: String!\n    lastName: String!\n    books: [Book!]!\n}\n```\n\nFrom here, KraphQL generates Kotlin code for the DSL.\n\nThen, we can use it to write the following DSL:\n\n```kotlin\n    @Test\n    fun query() {\n        val q = query {\n            books {\n                title\n                author {\n                    firstName\n                    lastName\n                }\n            }\n        }\n        \n        val expected = \"\"\"\n            query {\n              books {\n                title\n                author {\n                  firstName\n                  lastName\n                }\n              }\n            }\n        \"\"\".trimIndent()\n\n        val actual = formatQuery(q.toString()) // formatQuery just makes it look good\n\n        assertThat(actual).isEqualTo(expected)\n    }\n```\n\n## Usage\n\nKraphQL is available as [Gradle plugin](https://plugins.gradle.org/plugin/com.github.lusingander.kraphql-plugin).\n\nAdd the following to build.gradle:\n\n```groovy\nplugins {\n  id \"com.github.lusingander.kraphql-plugin\" version \"0.0.4\"\n}\n\nkraphql {\n    input = \"./schema.graphql\"\n    output = \"./output.kt\"\n    packageName = \"com.github.example\"\n}\n```\n\nThen, when you run the `kraphqlGenerateDsl` task, it will output the Kotlin DSL file.\n\nFor an example, see [kraphql-github](https://github.com/lusingander/kraphql-github).\n\n## Sample\n\nSee `./src/test/` directory, or see [Related projects](#related-projects).\n\n### Test codes\n\n[./src/test/kotlin/com/github/lusingander/kraphql/test](https://github.com/lusingander/kraphql/tree/master/src/test/kotlin/com/github/lusingander/kraphql/test)\n\n### Schema definitions\n\n[./src/test/resources/sdl](https://github.com/lusingander/kraphql/tree/master/src/test/resources/sdl)\n\n### Generated Kotlin codes\n\n[./src/test/kotlin/com/github/lusingander/kraphql/gen](https://github.com/lusingander/kraphql/tree/master/src/test/kotlin/com/github/lusingander/kraphql/gen)\n\n## Related projects\n\n- [lusingander/kraphql-github](https://github.com/lusingander/kraphql-github)\n  - Kotlin DSL for GitHub GraphQL API (GitHub API v4)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flusingander%2Fkraphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flusingander%2Fkraphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flusingander%2Fkraphql/lists"}