From d4599c3331cab595b810b870a48cf94a91a14751 Mon Sep 17 00:00:00 2001 From: Syer10 Date: Fri, 31 Mar 2023 19:09:32 -0400 Subject: [PATCH] Use Graphiql with the Explorer plugin for the query builder --- .../graphql/controller/GraphQLController.kt | 12 +- .../main/resources/graphql-playground.html | 126 +++++++++++------- 2 files changed, 77 insertions(+), 61 deletions(-) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/controller/GraphQLController.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/controller/GraphQLController.kt index 433b64d6..3c0c4e03 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/controller/GraphQLController.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/controller/GraphQLController.kt @@ -25,18 +25,10 @@ object GraphQLController { } fun playground(ctx: Context) { - val playgroundHtml = javaClass.getResource("/graphql-playground.html") - - val body = playgroundHtml.openStream().bufferedReader().use { reader -> - val graphQLEndpoint = "graphql" - val subscriptionsEndpoint = "graphql" - + val body = javaClass.getResourceAsStream("/graphql-playground.html")!!.bufferedReader().use { reader -> reader.readText() - .replace("\${graphQLEndpoint}", graphQLEndpoint) - .replace("\${subscriptionsEndpoint}", subscriptionsEndpoint) } - - ctx.html(body ?: "Could not load playground") + ctx.html(body) } fun webSocket(ws: WsConfig) { diff --git a/server/src/main/resources/graphql-playground.html b/server/src/main/resources/graphql-playground.html index 894ff66f..76407218 100644 --- a/server/src/main/resources/graphql-playground.html +++ b/server/src/main/resources/graphql-playground.html @@ -1,60 +1,84 @@ - - + - - - GraphQL Playground - - - + GraphiQL + + + + + + + + + -
- - -
Loading - GraphQL Playground -
-
- + ReactDOM.render( + React.createElement(GraphiQLWithExplorer), + document.getElementById('graphiql'), + ); + -