mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-03 19:04:39 -05:00
Subscriptions!
This commit is contained in:
@@ -7,20 +7,19 @@
|
||||
|
||||
package suwayomi.tachidesk.graphql.controller
|
||||
|
||||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
||||
import io.javalin.http.Context
|
||||
import suwayomi.tachidesk.graphql.impl.getGraphQLServer
|
||||
import io.javalin.websocket.WsConfig
|
||||
import suwayomi.tachidesk.graphql.server.TachideskGraphQLServer
|
||||
import suwayomi.tachidesk.server.JavalinSetup.future
|
||||
|
||||
object GraphQLController {
|
||||
private val mapper = jacksonObjectMapper()
|
||||
private val tachideskGraphQLServer = getGraphQLServer(mapper)
|
||||
private val server = TachideskGraphQLServer.create()
|
||||
|
||||
/** execute graphql query */
|
||||
fun execute(ctx: Context) {
|
||||
ctx.future(
|
||||
future {
|
||||
tachideskGraphQLServer.execute(ctx)
|
||||
server.execute(ctx)
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -39,4 +38,13 @@ object GraphQLController {
|
||||
|
||||
ctx.html(body ?: "Could not load playground")
|
||||
}
|
||||
|
||||
fun webSocket(ws: WsConfig) {
|
||||
ws.onMessage { ctx ->
|
||||
server.handleSubscriptionMessage(ctx)
|
||||
}
|
||||
ws.onClose { ctx ->
|
||||
server.handleSubscriptionDisconnect(ctx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user