Apollo Kotlin Execution Help

Ktor

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.0.3") // This sample uses netty as an engine. // See https://ktor.io/ for other choices. implementation("io.ktor:ktor-server-netty:2.3.11") }

apollo-execution-ktor provides an apolloModule(ExecutableSchema) function that adds a /graphql route to your application:

embeddedServer(Netty, port = 8080) { // /graphql route apolloModule(ServiceExecutableSchemaBuilder().build()) }.start(wait = true)

You can also opt in the Apollo Sandbox route by using apolloSandboxModule()

embeddedServer(Netty, port = 8080) { // /sandbox/index.html route apolloSandboxModule() }

apolloSandboxModule() adds a sandbox/index.html route to your application.

Open http://localhost:8080/sandbox/index.html and try out your API in the Apollo sandbox

Apollo Sandbox

Last modified: 29 August 2024