Apollo Kotlin Execution Help

Spring

Apollo Kotlin Execution comes with Spring Webflux integration.

To use the Spring Webflux integration, add apollo-execution-spring to your dependencies:

dependencies { // Add the runtime dependency implementation("com.apollographql.execution:apollo-execution-spring:0.0.3") }

apollo-execution-spring provides apolloGraphQLRoutes(ExecutableSchema) to add GET and POST /graphql routes to your application:

@SpringBootApplication class DefaultApplication { @Bean fun routes() = coRouter { apolloGraphQLRoutes(ServiceExecutableSchemaBuilder().build()) } }

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

@SpringBootApplication class DefaultApplication { @Bean fun routes() = coRouter { // /graphql routes apolloGraphQLRoutes(ServiceExecutableSchemaBuilder().build()) // /sandbox/index.html route apolloSandboxRoutes() } }

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: 05 September 2024