Skip to content

Commit 835d680

Browse files
timemanxTheDome0
andauthored
Update Ktor to 3.0.3 (#2066)
### 📝 Description Updated Ktor and updated failing tests and fixed compile issues resulting from the update. Also updated some libraries. ### 🔗 Related Issues #2037 --------- Co-authored-by: TheDome0 <[email protected]>
1 parent f1a8603 commit 835d680

File tree

17 files changed

+100
-95
lines changed

17 files changed

+100
-95
lines changed

examples/server/ktor-server/src/main/kotlin/com/expediagroup/graphql/examples/server/ktor/GraphQLModule.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ import io.ktor.server.application.Application
3737
import io.ktor.server.application.install
3838
import io.ktor.server.plugins.cors.routing.CORS
3939
import io.ktor.server.plugins.statuspages.StatusPages
40-
import io.ktor.server.routing.Routing
40+
import io.ktor.server.routing.routing
4141
import io.ktor.server.websocket.WebSockets
4242
import io.ktor.server.websocket.pingPeriod
43-
import java.time.Duration
43+
import kotlin.time.Duration.Companion.seconds
4444

4545
fun Application.graphQLModule() {
4646
install(WebSockets) {
47-
pingPeriod = Duration.ofSeconds(1)
47+
pingPeriod = 1.seconds
4848
contentConverter = JacksonWebsocketContentConverter()
4949
}
5050
install(StatusPages) {
@@ -78,7 +78,7 @@ fun Application.graphQLModule() {
7878
contextFactory = CustomGraphQLContextFactory()
7979
}
8080
}
81-
install(Routing) {
81+
routing {
8282
graphQLGetRoute()
8383
graphQLPostRoute()
8484
graphQLSubscriptionsRoute()

gradle/libs.versions.toml

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
[versions]
22
android-plugin = "8.5.0"
33
classgraph = "4.8.174"
4-
dataloader = "3.3.0"
5-
federation = "5.1.0"
6-
graphql-java = "22.1"
4+
dataloader = "3.4.0"
5+
federation = "5.2.0"
6+
graphql-java = "22.3"
77
graalvm = "0.10.2"
88
jackson = "2.17.1"
99
# kotlin version has to match the compile-testing compiler version
1010
kotlin = "2.0.0"
11-
kotlinx-benchmark = "0.4.11"
12-
kotlinx-coroutines = "1.8.1"
11+
kotlinx-benchmark = "0.4.13"
12+
kotlinx-coroutines = "1.9.0"
1313
# TODO kotlin 1.9 upgrade: fix GraphQLTestUtils and GenerateKotlinxClientIT
1414
kotlinx-serialization = "1.6.3"
15-
ktor = "2.3.12"
15+
ktor = "3.0.3"
1616
fastjson2 = "2.0.53"
1717
maven-plugin-annotation = "3.13.1"
1818
maven-plugin-api = "3.9.8"
@@ -33,16 +33,16 @@ compile-testing = "0.5.1"
3333
icu = "75.1"
3434
junit = "5.10.2"
3535
logback = "1.5.6"
36-
mockk = "1.13.11"
36+
mockk = "1.13.13"
3737
rxjava = "3.1.8"
3838
wiremock = "3.7.0"
3939

4040
# plugins
41-
detekt = "1.23.6"
42-
dokka = "1.9.20"
41+
detekt = "1.23.7"
42+
dokka = "2.0.0"
4343
jacoco = "0.8.12"
44-
ktlint-core = "1.3.0"
45-
ktlint-plugin = "12.1.1"
44+
ktlint-core = "1.5.0"
45+
ktlint-plugin = "12.1.2"
4646
maven-plugin-development = "0.4.3"
4747
nexus-publish-plugin = "2.0.0"
4848
plugin-publish = "1.2.1"

integration/graalvm/ktor-graalvm-server/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ graalvmNative {
3232
binaries {
3333
named("main") {
3434
verbose.set(true)
35-
buildArgs.add("--initialize-at-build-time=io.ktor,kotlin,ch.qos.logback,org.slf4j")
35+
buildArgs.add("--initialize-at-build-time=io.ktor,kotlin,kotlinx.io,ch.qos.logback,org.slf4j")
3636
buildArgs.add("-H:+ReportExceptionStackTraces")
3737
jvmArgs("-Xmx6g")
3838
}

integration/graalvm/maven-graalvm-server/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
<configuration>
171171
<verbose>true</verbose>
172172
<buildArgs>
173-
<arg>--initialize-at-build-time=io.ktor,kotlin,ch.qos.logback,org.slf4j</arg>
173+
<arg>--initialize-at-build-time=io.ktor,kotlin,kotlinx.io,ch.qos.logback,org.slf4j</arg>
174174
<arg>-H:+ReportExceptionStackTraces</arg>
175175
</buildArgs>
176176
<jvmArgs>

integration/gradle-plugin-integration-tests/client-generator/custom-scalars-kotlinx/src/main/kotlin/com/expediagroup/scalars/Application.kt

-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
55
import io.ktor.http.ContentType
66
import io.ktor.http.HttpStatusCode
77
import io.ktor.server.application.Application
8-
import io.ktor.server.application.call
9-
import io.ktor.server.application.install
108
import io.ktor.server.response.respond
119
import io.ktor.server.response.respondText
12-
import io.ktor.server.routing.Routing
1310
import io.ktor.server.routing.get
1411
import io.ktor.server.routing.post
1512
import io.ktor.server.routing.routing
@@ -20,7 +17,6 @@ fun Application.graphQLModule() {
2017
val jacksonObjectMapper: ObjectMapper = jacksonObjectMapper()
2118
val ktorGraphQLServer: KtorGraphQLServer = KtorGraphQLServer(jacksonObjectMapper)
2219

23-
install(Routing)
2420
routing {
2521
post("graphql") {
2622
val result = ktorGraphQLServer.execute(call.request)

integration/gradle-plugin-integration-tests/client-generator/custom-scalars-kotlinx/src/test/kotlin/com/expediagroup/scalars/CustomScalarKotlinxTests.kt

+17-17
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ class CustomScalarKotlinxTests {
3131

3232
@Test
3333
fun `verify custom scalars are correctly serialized and deserialized`() {
34-
val engine = embeddedServer(CIO, port = 0, module = Application::graphQLModule)
34+
val embeddedServer = embeddedServer(CIO, port = 0, module = Application::graphQLModule)
3535
try {
36-
engine.start()
36+
embeddedServer.start()
3737
runBlocking {
38-
val port = engine.resolvedConnectors().first().port
38+
val port = embeddedServer.engine.resolvedConnectors().first().port
3939
val client = GraphQLKtorClient(url = URL("http://localhost:$port/graphql"))
4040

4141
val undefinedLocaleQuery = LocaleQuery(variables = LocaleQuery.Variables())
@@ -52,17 +52,17 @@ class CustomScalarKotlinxTests {
5252
assertEquals(ULocale.CANADA, localeResult.data?.localeQuery)
5353
}
5454
} finally {
55-
engine.stop(1000, 1000)
55+
embeddedServer.stop(1000, 1000)
5656
}
5757
}
5858

5959
@Test
6060
fun `verify undefined optionals are correctly serialized and deserialized`() {
61-
val engine = embeddedServer(CIO, port = 0, module = Application::graphQLModule)
61+
val embeddedServer = embeddedServer(CIO, port = 0, module = Application::graphQLModule)
6262
try {
63-
engine.start()
63+
embeddedServer.start()
6464
runBlocking {
65-
val port = engine.resolvedConnectors().first().port
65+
val port = embeddedServer.engine.resolvedConnectors().first().port
6666
val client = GraphQLKtorClient(url = URL("http://localhost:$port/graphql"))
6767

6868
val undefinedWrapperQuery = OptionalScalarQuery(variables = OptionalScalarQuery.Variables())
@@ -97,15 +97,15 @@ class CustomScalarKotlinxTests {
9797
assertEquals(0, defaultResult.optionalUUIDList?.size)
9898
}
9999
} finally {
100-
engine.stop(1000, 1000)
100+
embeddedServer.stop(1000, 1000)
101101
}
102102
}
103103

104104
@Test
105105
fun `verify null optionals are correctly serialized and deserialized`() {
106-
val engine = embeddedServer(CIO, port = 8080, module = Application::graphQLModule)
106+
val embeddedServer = embeddedServer(CIO, port = 8080, module = Application::graphQLModule)
107107
try {
108-
engine.start()
108+
embeddedServer.start()
109109
runBlocking {
110110
val client = GraphQLKtorClient(url = URL("http://localhost:8080/graphql"))
111111

@@ -142,15 +142,15 @@ class CustomScalarKotlinxTests {
142142
assertNull(nullResult.optionalUUIDList)
143143
}
144144
} finally {
145-
engine.stop(1000, 1000)
145+
embeddedServer.stop(1000, 1000)
146146
}
147147
}
148148

149149
@Test
150150
fun `verify defined optionals are correctly serialized and deserialized`() {
151-
val engine = embeddedServer(CIO, port = 8080, module = Application::graphQLModule)
151+
val embeddedServer = embeddedServer(CIO, port = 8080, module = Application::graphQLModule)
152152
try {
153-
engine.start()
153+
embeddedServer.start()
154154
runBlocking {
155155
val client = GraphQLKtorClient(url = URL("http://localhost:8080/graphql"))
156156

@@ -187,15 +187,15 @@ class CustomScalarKotlinxTests {
187187
assertEquals(randomUUID, result.optionalUUIDList?.get(0))
188188
}
189189
} finally {
190-
engine.stop(1000, 1000)
190+
embeddedServer.stop(1000, 1000)
191191
}
192192
}
193193

194194
@Test
195195
fun `verify serialization and deserialization of required type`() {
196-
val engine = embeddedServer(CIO, port = 8080, module = Application::graphQLModule)
196+
val embeddedServer = embeddedServer(CIO, port = 8080, module = Application::graphQLModule)
197197
try {
198-
engine.start()
198+
embeddedServer.start()
199199
runBlocking {
200200
val client = GraphQLKtorClient(url = URL("http://localhost:8080/graphql"))
201201

@@ -232,7 +232,7 @@ class CustomScalarKotlinxTests {
232232
assertEquals(wrapper.requiredUUIDList[0], result.requiredUUIDList[0])
233233
}
234234
} finally {
235-
engine.stop(1000, 1000)
235+
embeddedServer.stop(1000, 1000)
236236
}
237237
}
238238
}

integration/gradle-plugin-integration-tests/client-generator/ktor-jackson/src/main/kotlin/com/expediagroup/ktor/jackson/Application.kt

-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
55
import io.ktor.http.ContentType
66
import io.ktor.http.HttpStatusCode
77
import io.ktor.server.application.Application
8-
import io.ktor.server.application.call
9-
import io.ktor.server.application.install
108
import io.ktor.server.response.respond
119
import io.ktor.server.response.respondText
12-
import io.ktor.server.routing.Routing
1310
import io.ktor.server.routing.get
1411
import io.ktor.server.routing.post
1512
import io.ktor.server.routing.routing
@@ -20,7 +17,6 @@ fun Application.graphQLModule() {
2017
val jacksonObjectMapper: ObjectMapper = jacksonObjectMapper()
2118
val ktorGraphQLServer: KtorGraphQLServer = KtorGraphQLServer(jacksonObjectMapper)
2219

23-
install(Routing)
2420
routing {
2521
post("graphql") {
2622
val result = ktorGraphQLServer.execute(call.request)

integration/gradle-plugin-integration-tests/client-generator/ktor-jackson/src/test/kotlin/com/expediagroup/ktor/jackson/ApplicationTest.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ import kotlin.test.assertNull
1818
class ApplicationTest {
1919
@Test
2020
fun `verify ktor client can execute queries`() {
21-
val engine = embeddedServer(CIO, port = 0, module = Application::graphQLModule)
21+
val embeddedServer = embeddedServer(CIO, port = 0, module = Application::graphQLModule)
2222
try {
23-
engine.start()
23+
embeddedServer.start()
2424
runBlocking {
25-
val port = engine.resolvedConnectors().first().port
25+
val port = embeddedServer.engine.resolvedConnectors().first().port
2626
val client = GraphQLKtorClient(url = URL("http://localhost:$port/graphql"))
2727

2828
val result = client.execute(TestQuery(variables = TestQuery.Variables(name = OptionalInput.Defined("junit"))))
@@ -40,7 +40,7 @@ class ApplicationTest {
4040
assertEquals(ExampleEnum.ONE.name, testObject.choice.name)
4141
}
4242
} finally {
43-
engine.stop(1000, 1000)
43+
embeddedServer.stop(1000, 1000)
4444
}
4545
}
4646
}

integration/gradle-plugin-integration-tests/client-generator/ktor-kotlinx/src/main/kotlin/com/expediagroup/ktor/kotlinx/Application.kt

-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
55
import io.ktor.http.ContentType
66
import io.ktor.http.HttpStatusCode
77
import io.ktor.server.application.Application
8-
import io.ktor.server.application.call
9-
import io.ktor.server.application.install
108
import io.ktor.server.response.respond
119
import io.ktor.server.response.respondText
12-
import io.ktor.server.routing.Routing
1310
import io.ktor.server.routing.get
1411
import io.ktor.server.routing.post
1512
import io.ktor.server.routing.routing
@@ -20,7 +17,6 @@ fun Application.graphQLModule() {
2017
val jacksonObjectMapper: ObjectMapper = jacksonObjectMapper()
2118
val ktorGraphQLServer: KtorGraphQLServer = KtorGraphQLServer(jacksonObjectMapper)
2219

23-
install(Routing)
2420
routing {
2521
post("graphql") {
2622
val result = ktorGraphQLServer.execute(call.request)

integration/gradle-plugin-integration-tests/client-generator/ktor-kotlinx/src/test/kotlin/com/expediagroup/ktor/kotlinx/ApplicationTest.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ import kotlin.test.assertNull
1818
class ApplicationTest {
1919
@Test
2020
fun `verify ktor client can execute queries`() {
21-
val engine = embeddedServer(CIO, port = 0, module = Application::graphQLModule)
21+
val embeddedServer = embeddedServer(CIO, port = 0, module = Application::graphQLModule)
2222
try {
23-
engine.start()
23+
embeddedServer.start()
2424
runBlocking {
25-
val port = engine.resolvedConnectors().first().port
25+
val port = embeddedServer.engine.resolvedConnectors().first().port
2626
val client = GraphQLKtorClient(url = URL("http://localhost:$port/graphql"))
2727

2828
val result = client.execute(TestQuery(variables = TestQuery.Variables(name = OptionalInput.Defined("junit"))))
@@ -40,7 +40,7 @@ class ApplicationTest {
4040
assertEquals(ExampleEnum.ONE.name, testObject.choice.name)
4141
}
4242
} finally {
43-
engine.stop(1000, 1000)
43+
embeddedServer.stop(1000, 1000)
4444
}
4545
}
4646
}

integration/gradle-plugin-integration-tests/client-generator/polymorphic-types-kotlinx/src/main/kotlin/com/expediagroup/polymorphic/Application.kt

-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
55
import io.ktor.http.ContentType
66
import io.ktor.http.HttpStatusCode
77
import io.ktor.server.application.Application
8-
import io.ktor.server.application.call
9-
import io.ktor.server.application.install
108
import io.ktor.server.response.respond
119
import io.ktor.server.response.respondText
12-
import io.ktor.server.routing.Routing
1310
import io.ktor.server.routing.get
1411
import io.ktor.server.routing.post
1512
import io.ktor.server.routing.routing
@@ -20,7 +17,6 @@ fun Application.graphQLModule() {
2017
val jacksonObjectMapper: ObjectMapper = jacksonObjectMapper()
2118
val ktorGraphQLServer: KtorGraphQLServer = KtorGraphQLServer(jacksonObjectMapper)
2219

23-
install(Routing)
2420
routing {
2521
post("graphql") {
2622
val result = ktorGraphQLServer.execute(call.request)

integration/gradle-plugin-integration-tests/client-generator/polymorphic-types-kotlinx/src/test/kotlin/com/expediagroup/polymorphic/PolymorphicKotlinxTests.kt

+8-8
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ class PolymorphicKotlinxTests {
2626

2727
@Test
2828
fun `verify polymorphic queries are correctly serialized and deserialized`() {
29-
val engine = embeddedServer(CIO, port = 0, module = Application::graphQLModule)
29+
val embeddedServer = embeddedServer(CIO, port = 0, module = Application::graphQLModule)
3030
try {
31-
engine.start()
31+
embeddedServer.start()
3232
runBlocking {
33-
val port = engine.resolvedConnectors().first().port
33+
val port = embeddedServer.engine.resolvedConnectors().first().port
3434
val client = GraphQLKtorClient(url = URL("http://localhost:$port/graphql"))
3535

3636
val query = CompletePolymorphicQuery(variables = CompletePolymorphicQuery.Variables(input = "foo"))
@@ -46,16 +46,16 @@ class PolymorphicKotlinxTests {
4646
assertNull(nullResponse.data?.unionQuery)
4747
}
4848
} finally {
49-
engine.stop(1000, 1000)
49+
embeddedServer.stop(1000, 1000)
5050
}
5151
}
5252

5353
@OptIn(ExperimentalSerializationApi::class)
5454
@Test
5555
fun `verify polymorphic queries fallbacks are correctly serialized and deserialized`() {
56-
val engine = embeddedServer(CIO, port = 0, module = Application::graphQLModule)
56+
val embeddedServer = embeddedServer(CIO, port = 0, module = Application::graphQLModule)
5757
try {
58-
engine.start()
58+
embeddedServer.start()
5959
runBlocking {
6060
// need to register fallback logic
6161
val serializerWithFallback = GraphQLClientKotlinxSerializer(jsonBuilder = {
@@ -68,7 +68,7 @@ class PolymorphicKotlinxTests {
6868
}
6969
}
7070
})
71-
val port = engine.resolvedConnectors().first().port
71+
val port = embeddedServer.engine.resolvedConnectors().first().port
7272
val client = GraphQLKtorClient(url = URL("http://localhost:$port/graphql"), serializer = serializerWithFallback)
7373

7474
val fallbackQuery = PartialPolymorphicQuery(variables = PartialPolymorphicQuery.Variables(input = "bar"))
@@ -79,7 +79,7 @@ class PolymorphicKotlinxTests {
7979
assertTrue(unionResult is DefaultBasicUnionImplementation)
8080
}
8181
} finally {
82-
engine.stop(1000, 1000)
82+
embeddedServer.stop(1000, 1000)
8383
}
8484
}
8585
}

integration/graphql-http-spec/ktor-server/src/main/kotlin/com/expediagroup/http/spec/ktor/GraphQLModule.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import com.expediagroup.graphql.server.ktor.graphQLGetRoute
2020
import com.expediagroup.graphql.server.ktor.graphQLPostRoute
2121
import io.ktor.server.application.Application
2222
import io.ktor.server.application.install
23-
import io.ktor.server.routing.Routing
23+
import io.ktor.server.routing.routing
2424

2525
fun Application.graphQLModule() {
2626
install(GraphQL) {
@@ -31,7 +31,7 @@ fun Application.graphQLModule() {
3131
)
3232
}
3333
}
34-
install(Routing) {
34+
routing {
3535
graphQLGetRoute()
3636
graphQLPostRoute()
3737
}

0 commit comments

Comments
 (0)