Getting started
Apollo Kotlin Execution is a code-first GraphQL execution library.
Apollo Kotlin Execution:
Generates a GraphQL schema from your Kotlin code: write Kotlin, get a typesafe API.
Doesn't use reflection. Use it on the JVM and enjoy ultra-fast start times. Or use it with Kotlin native. Apollo Kotlin Execution is KMP-ready!
Supports custom scalars, subscriptions, persisted queries and everything in the current GraphQL draft.
Supports Apollo Federation.
Under the hood, Apollo Kotlin Execution uses KSP to generate GraphQL resolvers and types from your Kotlin code.
Gradle configuration
Apollo Kotlin Execution comes with a Gradle plugin that:
Configures KSP:
Adds
apollo-execution-processor
to the KSP configuration.Configure
service
&packageName
KSP arguments.
Configures dependency resolution to align Apollo Kotlin Execution versions if none is specified.
Adds
apolloCheckSchema
andapolloDumpSchema
tasks (see Monitoring the generated schema)
Configure your Gradle build:
Define your root query
Write your root query class in a Query.kt
file:
Run the codegen:
Execute your query
The codegen generates a com.example.ServiceExecutableSchemaBuilder
class that is the entry point to execute GraphQL requests:
Create a GraphQL request:
Execute the GraphQL request:
Apollo Kotlin Execution supports objects, interfaces, unions, enum, input objects, deprecation, customizing names and descriptions and more.
See the Generating a schema page for more details.
Integrate with your favorite server library
Apollo Kotlin Execution comes with integrations for popular server libraries:
See the respective documentation for how to configure a server with an ExecutableSchema
.