KGraphQL is Kotlin implementation of GraphQL. It provides rich DSL to setup GraphQL schema.
data class Article(val id: Int, val text: String)
fun main() {
val schema = KGraphQL.schema {
query("article") {
resolver { id: Int?, text: String ->
Article(id ?: -1, text)
}
}
type<Article> {
property<String>("fullText") {
resolver { article: Article ->
"${article.id}: ${article.text}"
}
}
}
}
schema.execute("""
{
article(id: 5, text: "Hello World") {
id
fullText
}
}
""".trimIndent()).let(::println)
}
See the documentation for a more detailed explanation of the library.
All contributions are welcome. Feel free to open issues and PRs!
To build KGraphQL you only need to have JDK8 installed. invoke
./gradlew build
To perform local build.
The versioning is following Semantic Versioning
Specification : http://facebook.github.io/graphql/
KGraphQL is Open Source software released under the MIT license