11package io.github.ermadmi78.kobby.cinema.client
22
3- import com.fasterxml.jackson.annotation.JsonCreator
4- import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
5- import com.fasterxml.jackson.module.paramnames.ParameterNamesModule
63import io.github.ermadmi78.kobby.cinema.api.kobby.kotlin.*
74import io.github.ermadmi78.kobby.cinema.api.kobby.kotlin.adapter.ktor.CinemaCompositeKtorAdapter
85import io.ktor.client.*
@@ -15,7 +12,6 @@ import kotlinx.coroutines.runBlocking
1512import org.springframework.boot.CommandLineRunner
1613import org.springframework.boot.autoconfigure.SpringBootApplication
1714import org.springframework.boot.runApplication
18- import kotlin.reflect.KClass
1915
2016/* *
2117 * Created on 16.10.2021
@@ -216,31 +212,19 @@ class Application : CommandLineRunner {
216212 private fun createKtorAdapter (): CinemaAdapter {
217213 // Create Ktor http client
218214 val client = HttpClient (CIO ) {
215+ expectSuccess = true
219216 install(WebSockets )
220217 }
221218
222- // Create Jackson object mapper
223- val mapper = jacksonObjectMapper()
224- .registerModule(ParameterNamesModule (JsonCreator .Mode .PROPERTIES ))
225-
226- // Create default implementation of CinemaAdapter
227- // Note, you can write your own implementation
219+ // Default implementation of CinemaAdapter.
220+ // Note, you can write your own implementation.
228221 return CinemaCompositeKtorAdapter (
229222 client,
230223 " http://localhost:8080/graphql" ,
231- " ws://localhost:8080/graphql" ,
232- object : CinemaMapper {
233- override fun serialize (value : Any ): String =
234- mapper.writeValueAsString(value)
235-
236- override fun <T : Any > deserialize (content : String , contentType : KClass <T >): T =
237- mapper.readValue(content, contentType.java)
238- }
224+ " ws://localhost:8080/graphql"
239225 ) {
240226 println (" >> ${it.query} " )
241- if (! it.variables.isNullOrEmpty()) {
242- println (" >> ${it.variables} " )
243- }
227+ println (" >> ${it.variables} " )
244228 }
245229 }
246230}
0 commit comments