To set up an endpoint at the default route (your.domain/graphql) with just a query resolver and without a custom GraphQL context:
fun Application.main() {
install(Routing) {
graphQL(
"path/to/schema.graphqls",
MyQueryResolver()
)
}
}Setting up an endpoint at your.domain/subroute/my-custom-endpoint with a custom GraphQL context and multiple resolvers:
fun Application.main() {
install(Routing) {
route("subroute") {
graphQL(
"my-custom-endpoint",
"path/to/schema.graphqls",
::MyContext,
Query(),
Mutation(),
AnotherResolver()
)
graphiQL()
}
}
}
data class MyContext(val call: ApplicationCall)