Ktor is an asynchronous framework for creating microservices, web applications, and more.
Build the application by running the following from examples root directory:
# build example
./gradlew ktor-server:build
NOTE: in order to ensure you use the right version of Gradle we highly recommend that you use the provided wrapper scripts
Start the server by running Application.kt
directly from your IDE. (Make sure that your Kotlin Compiler jvm target is 1.8 or greater.)
Alternatively, you can start the server using Gradle.
cd /path/to/graphql-kotlin/examples
./gradlew ktor-server:run
Once the app has started you can:
- Explore and interact with the example schema by opening the Playground IDE endpoint at http://localhost:8080/graphiql
- Send GraphQL requests directly to the endpoint at http://localhost:8080/graphql
You can use the following example query to view several of the related models:
query {
searchCourses(params: { ids: [1,2,3] }) {
id
name
books {
title
}
university {
id
name
}
}
searchUniversities(params: { ids: [1]}) {
id
name
}
}
You can also query the longThatNeverComes
field from several of the types. This will throw and exception,
allow you to see how the ExecutionStrategy
handles throw exceptions in different levels of the query.