Skip to content

Commit

Permalink
Upgrade to ktor version 3
Browse files Browse the repository at this point in the history
  • Loading branch information
ronjunevaldoz committed Sep 28, 2024
1 parent dd3ad23 commit 5d9bd6f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ kotlinx-benchmark = "0.4.11"
kotlinx-coroutines = "1.8.1"
# TODO kotlin 1.9 upgrade: fix GraphQLTestUtils and GenerateKotlinxClientIT
kotlinx-serialization = "1.6.3"
ktor = "2.3.12"
ktor = "3.0.0-rc-1"
maven-plugin-annotation = "3.13.1"
maven-plugin-api = "3.9.8"
maven-project = "2.2.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ fun Route.graphiQLRoute(
graphQLEndpoint: String = "graphql",
subscriptionsEndpoint: String = "subscriptions",
): Route {
val contextPath = this.environment?.rootPath
val contextPath = this.application.rootPath
val graphiQL = GraphQL::class.java.classLoader.getResourceAsStream("graphql-graphiql.html")?.bufferedReader()?.use { reader ->
reader.readText()
.replace("\${graphQLEndpoint}", if (contextPath.isNullOrBlank()) graphQLEndpoint else "$contextPath/$graphQLEndpoint")
.replace("\${subscriptionsEndpoint}", if (contextPath.isNullOrBlank()) subscriptionsEndpoint else "$contextPath/$subscriptionsEndpoint")
.replace("\${graphQLEndpoint}", if (contextPath.isBlank()) graphQLEndpoint else "$contextPath/$graphQLEndpoint")
.replace("\${subscriptionsEndpoint}", if (contextPath.isBlank()) subscriptionsEndpoint else "$contextPath/$subscriptionsEndpoint")
} ?: throw IllegalStateException("Unable to load GraphiQL")
return get(endpoint) {
call.respondText(graphiQL, ContentType.Text.Html)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import io.ktor.serialization.jackson.jackson
import io.ktor.server.application.Application
import io.ktor.server.application.install
import io.ktor.server.plugins.statuspages.StatusPages
import io.ktor.server.routing.Routing
import io.ktor.server.routing.*
import io.ktor.server.testing.testApplication
import io.ktor.websocket.Frame
import io.ktor.websocket.readText
Expand Down Expand Up @@ -260,7 +260,7 @@ fun Application.testGraphQLModule() {
}
}
install(io.ktor.server.websocket.WebSockets)
install(Routing) {
routing {
graphQLGetRoute()
graphQLPostRoute()
graphQLSubscriptionsRoute()
Expand Down

0 comments on commit 5d9bd6f

Please sign in to comment.