File tree Expand file tree Collapse file tree
src/main/kotlin/io/github/ermadmi78/kobby/cinema/client
kotlin/io/github/ermadmi78/kobby/cinema/server Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ The GraphQL Client DSL code in this tutorial is generated using the [Kobby Plugi
881 . Clone this tutorial
991 . See GraphQL schema [ here] ( https://github.com/ermadmi78/kobby-gradle-tutorial/blob/main/cinema-api/src/main/resources/io/github/ermadmi78/kobby/cinema/api/cinema.graphqls )
10101 . Start server: ` ./gradlew :cinema-server:bootRun `
11- 1 . Try to execute GraphQL queries in [ console] ( http://localhost:8080/playground ) (for example ` query { films { id title } } ` )
11+ 1 . Try to execute GraphQL queries in [ console] ( http://localhost:8080/graphiql ) (for example ` query { films { id title } } ` )
12121 . Start client: ` ./gradlew :cinema-client:bootRun `
13131 . See queries, generated by Kobby DSL in client output
14141 . See client source code [ here] ( https://github.com/ermadmi78/kobby-gradle-tutorial/blob/main/cinema-client/src/main/kotlin/io/github/ermadmi78/kobby/cinema/client/application.kt )
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ description = "Cinema API"
22
33plugins {
44 kotlin(" jvm" )
5- id(" io.github.ermadmi78.kobby" ) version " 3.1.0 "
5+ id(" io.github.ermadmi78.kobby" ) version " 4.0.0-alpha.01 "
66}
77
88kotlin {
@@ -11,8 +11,8 @@ kotlin {
1111
1212dependencies {
1313 // Add this dependency to enable Jackson annotation generation in DTO classes
14- compileOnly(" com.fasterxml.jackson.core:jackson-annotations:2.15.3 " )
14+ compileOnly(" com.fasterxml.jackson.core:jackson-annotations:2.15.4 " )
1515
1616 // Add this dependency to enable default Ktor adapters generation
17- compileOnly(" io.ktor:ktor-client-cio:2.3.6 " )
17+ compileOnly(" io.ktor:ktor-client-cio:2.3.9 " )
1818}
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ description = "Cinema Client"
33plugins {
44 kotlin(" jvm" )
55 id(" org.jetbrains.kotlin.plugin.spring" )
6- id(" org.springframework.boot" ) version " 3.1.5 "
6+ id(" org.springframework.boot" ) version " 3.2.4 "
77}
88
99kotlin {
@@ -16,13 +16,13 @@ dependencies {
1616 implementation(platform(org.springframework.boot.gradle.plugin.SpringBootPlugin .BOM_COORDINATES ))
1717 implementation(" org.springframework.boot:spring-boot-starter" )
1818
19- implementation(" com.fasterxml.jackson.module:jackson-module-kotlin:2.15.3 " )
20- implementation(" com.fasterxml.jackson.module:jackson-module-parameter-names:2.15.3 " )
19+ implementation(" com.fasterxml.jackson.module:jackson-module-kotlin:2.15.4 " )
20+ implementation(" com.fasterxml.jackson.module:jackson-module-parameter-names:2.15.4 " )
2121
22- implementation(" org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3 " )
22+ implementation(" org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0 " )
2323
24- implementation(" io.ktor:ktor-client-cio:2.3.6 " )
25- implementation(" io.ktor:ktor-client-websockets:2.3.6 " )
24+ implementation(" io.ktor:ktor-client-cio:2.3.9 " )
25+ implementation(" io.ktor:ktor-client-websockets:2.3.9 " )
2626
2727 implementation(kotlin(" stdlib" ))
2828 implementation(kotlin(" reflect" ))
Original file line number Diff line number Diff line change @@ -228,7 +228,7 @@ class Application : CommandLineRunner {
228228 return CinemaCompositeKtorAdapter (
229229 client,
230230 " http://localhost:8080/graphql" ,
231- " ws://localhost:8080/subscriptions " ,
231+ " ws://localhost:8080/graphql " ,
232232 object : CinemaMapper {
233233 override fun serialize (value : Any ): String =
234234 mapper.writeValueAsString(value)
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ description = "Cinema Server"
55plugins {
66 kotlin(" jvm" )
77 id(" org.jetbrains.kotlin.plugin.spring" )
8- id(" org.springframework.boot" ) version " 3.1.5 "
8+ id(" org.springframework.boot" ) version " 3.2.4 "
99}
1010
1111kotlin {
@@ -15,16 +15,16 @@ kotlin {
1515dependencies {
1616 implementation(project(" :cinema-api" ))
1717
18- implementation(" com.graphql-java-kickstart:graphql-spring-boot-starter:15.0.0" )
19-
2018 implementation(platform(SpringBootPlugin .BOM_COORDINATES ))
19+ implementation(" org.springframework.boot:spring-boot-starter-graphql" )
2120 implementation(" org.springframework.boot:spring-boot-starter-webflux" )
21+ implementation(" org.springframework.data:spring-data-commons" )
2222
23- implementation(" com.fasterxml.jackson.module:jackson-module-kotlin:2.15.3 " )
23+ implementation(" com.fasterxml.jackson.module:jackson-module-kotlin:2.15.4 " )
2424
2525 implementation(kotlin(" stdlib" ))
2626 implementation(kotlin(" reflect" ))
2727
28- implementation(" org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3 " )
29- implementation(" org.jetbrains.kotlinx:kotlinx-coroutines-reactive :1.7.3 " )
28+ implementation(" org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0 " )
29+ implementation(" org.jetbrains.kotlinx:kotlinx-coroutines-reactor :1.8.0 " )
3030}
Original file line number Diff line number Diff line change 1+ package io.github.ermadmi78.kobby.cinema.server.controller
2+
3+ import io.github.ermadmi78.kobby.cinema.api.kobby.kotlin.dto.FilmDto
4+ import io.github.ermadmi78.kobby.cinema.server.dao.CinemaDao
5+ import io.github.ermadmi78.kobby.cinema.server.eventbus.EventBus
6+ import org.springframework.graphql.data.method.annotation.Argument
7+ import org.springframework.graphql.data.method.annotation.SchemaMapping
8+ import org.springframework.stereotype.Controller
9+
10+ /* *
11+ * Created on 16.10.2021
12+ *
13+ * @author Dmitry Ermakov (ermadmi78@gmail.com)
14+ */
15+ @Controller
16+ @SchemaMapping(typeName = " Mutation" )
17+ class MutationController (
18+ private val cinemaDao : CinemaDao ,
19+ private val eventBus : EventBus
20+ ) {
21+ @SchemaMapping
22+ suspend fun createFilm (@Argument title : String ): FilmDto = cinemaDao.createFilm(title).also {
23+ eventBus.fireFilmCreated(it)
24+ }
25+ }
Original file line number Diff line number Diff line change 1+ package io.github.ermadmi78.kobby.cinema.server.controller
2+
3+ import io.github.ermadmi78.kobby.cinema.api.kobby.kotlin.dto.FilmDto
4+ import io.github.ermadmi78.kobby.cinema.server.dao.CinemaDao
5+ import org.springframework.graphql.data.method.annotation.Argument
6+ import org.springframework.graphql.data.method.annotation.SchemaMapping
7+ import org.springframework.stereotype.Controller
8+
9+ /* *
10+ * Created on 16.10.2021
11+ *
12+ * @author Dmitry Ermakov (ermadmi78@gmail.com)
13+ */
14+ @Controller
15+ @SchemaMapping(typeName = " Query" )
16+ class QueryController (
17+ private val cinemaDao : CinemaDao
18+ ) {
19+ @SchemaMapping
20+ suspend fun film (@Argument id : Long ): FilmDto ? = cinemaDao.findFilm(id)
21+
22+ @SchemaMapping
23+ suspend fun films (): List <FilmDto > = cinemaDao.findFilms()
24+ }
Original file line number Diff line number Diff line change 1+ package io.github.ermadmi78.kobby.cinema.server.controller
2+
3+ import io.github.ermadmi78.kobby.cinema.api.kobby.kotlin.dto.FilmDto
4+ import io.github.ermadmi78.kobby.cinema.server.eventbus.EventBus
5+ import kotlinx.coroutines.reactor.asFlux
6+ import org.springframework.graphql.data.method.annotation.SchemaMapping
7+ import org.springframework.stereotype.Controller
8+ import reactor.core.publisher.Flux
9+
10+ /* *
11+ * Created on 16.10.2021
12+ *
13+ * @author Dmitry Ermakov (ermadmi78@gmail.com)
14+ */
15+ @Controller
16+ @SchemaMapping(typeName = " Subscription" )
17+ class SubscriptionController (
18+ private val eventBus : EventBus
19+ ) {
20+ @SchemaMapping
21+ suspend fun filmCreated (): Flux <FilmDto > = eventBus.filmCreatedFlow().asFlux()
22+ }
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments