mirror of
https://github.com/Suwayomi/Tachidesk.git
synced 2026-02-01 00:14:12 +01:00
Rewrite graphql controller execute as function without docs
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user