Skip to content

Commit a2d781b

Browse files
authored
[client] update GraphQLWebClient to correctly apply codecs (#900)
Apply default codecs for JSON encoder/decoder without overwriting whole exchange strategies. Resolves: #899
1 parent 78debb2 commit a2d781b

File tree

1 file changed

+5
-9
lines changed
  • clients/graphql-kotlin-spring-client/src/main/kotlin/com/expediagroup/graphql/client

1 file changed

+5
-9
lines changed

clients/graphql-kotlin-spring-client/src/main/kotlin/com/expediagroup/graphql/client/GraphQLWebClient.kt

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import kotlinx.coroutines.reactive.awaitSingle
2525
import org.springframework.http.MediaType
2626
import org.springframework.http.codec.json.Jackson2JsonDecoder
2727
import org.springframework.http.codec.json.Jackson2JsonEncoder
28-
import org.springframework.web.reactive.function.client.ExchangeStrategies
2928
import org.springframework.web.reactive.function.client.WebClient
3029

3130
/**
@@ -42,16 +41,13 @@ open class GraphQLWebClient(
4241
init {
4342
mapper.enable(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE)
4443

45-
val strategies = ExchangeStrategies
46-
.builder()
47-
.codecs { configurer ->
48-
configurer.defaultCodecs().jackson2JsonEncoder(Jackson2JsonEncoder(mapper, MediaType.APPLICATION_JSON))
49-
configurer.defaultCodecs().jackson2JsonDecoder(Jackson2JsonDecoder(mapper, MediaType.APPLICATION_JSON))
50-
}.build()
51-
builder.exchangeStrategies(strategies)
44+
builder.codecs { codecConfigurer ->
45+
codecConfigurer.defaultCodecs().jackson2JsonEncoder(Jackson2JsonEncoder(mapper, MediaType.APPLICATION_JSON))
46+
codecConfigurer.defaultCodecs().jackson2JsonDecoder(Jackson2JsonDecoder(mapper, MediaType.APPLICATION_JSON))
47+
}
5248
}
5349

54-
private val client = builder.baseUrl(url).build()
50+
private val client: WebClient = builder.baseUrl(url).build()
5551

5652
/**
5753
* Executes specified GraphQL query or mutation.

0 commit comments

Comments
 (0)