Spring
Galak comes with Spring Webflux integration.
Add galak-spring to your project
Make sure to follow the steps in “Getting started” first to generate your
ServiceExecutableSchemaBuilder.
To use the Spring Webflux integration, add galak-spring to your dependencies:
dependencies { // Add the runtime dependency implementation("net.mbonnin.galak:galak-spring:0.0.0")}galak-spring provides galakRoutes(ExecutableSchema) to add GET and POST /graphql routes to your application:
@SpringBootApplicationclass DefaultApplication { @Bean fun routes() = coRouter { galakRoutes(ServiceExecutableSchemaBuilder().build()) }}
ServiceExecutableSchemaBuilderis generated by the KSP processor. See “Getting started” for more details.
You can also opt in the Apollo Sandbox route by using apolloSandboxRoutes()
@SpringBootApplicationclass DefaultApplication { @Bean fun routes() = coRouter { // /graphql routes galakRoutes(ServiceExecutableSchemaBuilder().build()) // /sandbox/index.html route apolloSandboxRoutes() }}galakSandboxModule() 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
