Rewrite graphql controller execute as function without docs

This commit is contained in:
Valter Martinek
2022-11-11 16:12:24 +01:00
committed by Syer10
parent 0c555e88d3
commit e2fa003239
2 changed files with 7 additions and 22 deletions

View File

@@ -12,7 +12,7 @@ import suwayomi.tachidesk.graphql.controller.GraphQLController
object GraphQL {
fun defineEndpoints() {
post("graphql", GraphQLController.execute)
post("graphql", GraphQLController::execute)
// graphql playground
get("graphql", GraphQLController::playground)

View File

@@ -9,36 +9,21 @@ package suwayomi.tachidesk.graphql.controller
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import io.javalin.http.Context
import io.javalin.http.HttpCode
import suwayomi.tachidesk.graphql.impl.getGraphQLServer
import suwayomi.tachidesk.server.JavalinSetup.future
import suwayomi.tachidesk.server.util.handler
import suwayomi.tachidesk.server.util.withOperation
object GraphQLController {
private val mapper = jacksonObjectMapper()
private val tachideskGraphQLServer = getGraphQLServer(mapper)
/** execute graphql query */
val execute = handler(
documentWith = {
withOperation {
summary("GraphQL endpoint")
description("Endpoint for GraphQL endpoints")
fun execute(ctx: Context) {
ctx.future(
future {
tachideskGraphQLServer.execute(ctx)
}
},
behaviorOf = { ctx ->
ctx.future(
future {
tachideskGraphQLServer.execute(ctx)
}
)
},
withResults = {
json<Any>(HttpCode.OK)
}
)
)
}
fun playground(ctx: Context) {
val playgroundHtml = javaClass.getResource("/graphql-playground.html")