Skip to content

Commit ab6934b

Browse files
committed
rootPath is no longer of ApplicationEnvironment
1 parent c1c2254 commit ab6934b

File tree

1 file changed

+3
-5
lines changed
  • servers/graphql-kotlin-ktor-server/src/main/kotlin/com/expediagroup/graphql/server/ktor

1 file changed

+3
-5
lines changed

servers/graphql-kotlin-ktor-server/src/main/kotlin/com/expediagroup/graphql/server/ktor/GraphQLRoutes.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ import com.expediagroup.graphql.server.execution.subscription.GRAPHQL_WS_PROTOCO
2121
import com.fasterxml.jackson.databind.ObjectMapper
2222
import io.ktor.http.ContentType
2323
import io.ktor.serialization.jackson.jackson
24-
import io.ktor.server.application.call
25-
import io.ktor.server.application.install
2624
import io.ktor.server.application.plugin
2725
import io.ktor.server.plugins.contentnegotiation.ContentNegotiation
2826
import io.ktor.server.response.respondText
@@ -115,11 +113,11 @@ fun Route.graphiQLRoute(
115113
graphQLEndpoint: String = "graphql",
116114
subscriptionsEndpoint: String = "subscriptions",
117115
): Route {
118-
val contextPath = this.environment?.rootPath
116+
val contextPath = this.application.rootPath
119117
val graphiQL = GraphQL::class.java.classLoader.getResourceAsStream("graphql-graphiql.html")?.bufferedReader()?.use { reader ->
120118
reader.readText()
121-
.replace("\${graphQLEndpoint}", if (contextPath.isNullOrBlank()) graphQLEndpoint else "$contextPath/$graphQLEndpoint")
122-
.replace("\${subscriptionsEndpoint}", if (contextPath.isNullOrBlank()) subscriptionsEndpoint else "$contextPath/$subscriptionsEndpoint")
119+
.replace("\${graphQLEndpoint}", if (contextPath.isBlank()) graphQLEndpoint else "$contextPath/$graphQLEndpoint")
120+
.replace("\${subscriptionsEndpoint}", if (contextPath.isBlank()) subscriptionsEndpoint else "$contextPath/$subscriptionsEndpoint")
123121
} ?: throw IllegalStateException("Unable to load GraphiQL")
124122
return get(endpoint) {
125123
call.respondText(graphiQL, ContentType.Text.Html)

0 commit comments

Comments
 (0)