mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-03 19:04:39 -05: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 {
|
object GraphQL {
|
||||||
fun defineEndpoints() {
|
fun defineEndpoints() {
|
||||||
post("graphql", GraphQLController.execute)
|
post("graphql", GraphQLController::execute)
|
||||||
|
|
||||||
// graphql playground
|
// graphql playground
|
||||||
get("graphql", GraphQLController::playground)
|
get("graphql", GraphQLController::playground)
|
||||||
|
|||||||
@@ -9,36 +9,21 @@ package suwayomi.tachidesk.graphql.controller
|
|||||||
|
|
||||||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
||||||
import io.javalin.http.Context
|
import io.javalin.http.Context
|
||||||
import io.javalin.http.HttpCode
|
|
||||||
import suwayomi.tachidesk.graphql.impl.getGraphQLServer
|
import suwayomi.tachidesk.graphql.impl.getGraphQLServer
|
||||||
import suwayomi.tachidesk.server.JavalinSetup.future
|
import suwayomi.tachidesk.server.JavalinSetup.future
|
||||||
import suwayomi.tachidesk.server.util.handler
|
|
||||||
import suwayomi.tachidesk.server.util.withOperation
|
|
||||||
|
|
||||||
object GraphQLController {
|
object GraphQLController {
|
||||||
private val mapper = jacksonObjectMapper()
|
private val mapper = jacksonObjectMapper()
|
||||||
private val tachideskGraphQLServer = getGraphQLServer(mapper)
|
private val tachideskGraphQLServer = getGraphQLServer(mapper)
|
||||||
|
|
||||||
/** execute graphql query */
|
/** execute graphql query */
|
||||||
val execute = handler(
|
fun execute(ctx: Context) {
|
||||||
documentWith = {
|
ctx.future(
|
||||||
withOperation {
|
future {
|
||||||
summary("GraphQL endpoint")
|
tachideskGraphQLServer.execute(ctx)
|
||||||
description("Endpoint for GraphQL endpoints")
|
|
||||||
}
|
}
|
||||||
},
|
)
|
||||||
|
}
|
||||||
behaviorOf = { ctx ->
|
|
||||||
ctx.future(
|
|
||||||
future {
|
|
||||||
tachideskGraphQLServer.execute(ctx)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
withResults = {
|
|
||||||
json<Any>(HttpCode.OK)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
fun playground(ctx: Context) {
|
fun playground(ctx: Context) {
|
||||||
val playgroundHtml = javaClass.getResource("/graphql-playground.html")
|
val playgroundHtml = javaClass.getResource("/graphql-playground.html")
|
||||||
|
|||||||
Reference in New Issue
Block a user