GraphQL Kotlin Ktor Plugin
Ktor plugin for graphql-kotlin.
Also provides subscriptions implementation for protocols graphql-ws and graphql-transport-ws.
๐ฆ Modules
- graphql-kotlin-ktor-plugin - Ktor plugin
- graphql-kotlin-ktor-subscriptions - GraphQL subscriptions implementation for Ktor
- example - Ktor server example
Usage
dependencies {
implementation("io.github.darkxanter.graphql", "graphql-kotlin-ktor-plugin", "<last-version>")
}fun Application.configureGraphQLModule() {
install(ContentNegotiation) {
jackson()
}
install(CallLogging)
install(WebSockets)
install(GraphQLKotlin) {
queries = listOf(
HelloQueryService(),
)
subscriptions = listOf(
SimpleSubscription()
)
schemaGeneratorConfig {
supportedPackages = listOf("example.graphql")
}
generateContextMap { request ->
val loggedInUser = User(
email = "johndoe@example.com",
firstName = "John",
lastName = "Doe",
)
mapOf(
"AuthorizedContext" to AuthorizedContext(loggedInUser)
)
}
}
}On this page
Languages
Kotlin83.7%TypeScript11.3%Vue2.9%HTML1.3%CSS0.8%
Contributors
MIT License
Created June 19, 2022
Updated December 24, 2023