Ktor
Add apollo-execution-ktor to your project
To use the Ktor integration, add apollo-execution-ktor to your dependencies and a Ktor engine:
dependencies {
// Add the runtime dependency
implementation("com.apollographql.execution:apollo-execution-ktor:0.1.1")
// This sample uses netty as an engine.
// See https://ktor.io/ for other choices.
implementation("io.ktor:ktor-server-netty:3.0.0")
}
apollo-execution-ktor provides 3 modules:
apolloModule(ExecutableSchema)adds the main/graphqlroute for queries/mutations.apolloSubscriptionModule(ExecutableSchema)adds the/subscriptionroute for subscriptions.apolloSandboxModule(ExecutableSchema)adds the/sandbox/index.htmlfor the online IDE
embeddedServer(Netty, port = 8080) {
val executableSchema = ServiceExecutableSchemaBuilder().build()
// /graphql route
apolloModule(executableSchema)
// /subscription route
apolloSubscriptionModule(executableSchema)
// /sandbox/index.html route
apolloSandboxModule()
}.start(wait = true)
Last modified: 16 December 2024