Skip to content

Commit abb9f42

Browse files
authored
GraphQL client fixes (#709)
* client implements closeable * fix GenerateClientMojo custom scalar parameter definition to match annotation
1 parent 040c290 commit abb9f42

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

graphql-kotlin-client/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ With Maven:
3434
With Gradle (example using kts):
3535

3636
```kotlin
37-
compile("com.expediagroup:graphql-kotlin-client:$latestVersion")
37+
implementation("com.expediagroup:graphql-kotlin-client:$latestVersion")
3838
```
3939

4040
## Use it

graphql-kotlin-client/src/main/kotlin/com/expediagroup/graphql/client/GraphQLClient.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import io.ktor.client.request.post
3131
import io.ktor.http.ContentType
3232
import io.ktor.http.contentType
3333
import io.ktor.util.KtorExperimentalAPI
34+
import java.io.Closeable
3435
import java.net.URL
3536

3637
/**
@@ -42,7 +43,7 @@ class GraphQLClient(
4243
private val mapper: ObjectMapper = jacksonObjectMapper(),
4344
engine: HttpClientEngineFactory<*> = CIO,
4445
vararg features: HttpClientFeature<*, *>
45-
) {
46+
) : Closeable {
4647
private val typeCache = mutableMapOf<Class<*>, JavaType>()
4748
init {
4849
mapper.enable(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE)
@@ -96,4 +97,8 @@ class GraphQLClient(
9697
mapper.typeFactory.constructParametricType(GraphQLResult::class.java, resultType)
9798
}
9899
}
100+
101+
override fun close() {
102+
client.close()
103+
}
99104
}

plugins/graphql-kotlin-maven-plugin/src/main/kotlin/com/expediagroup/graphql/plugin/maven/GenerateClientMojo.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class GenerateClientMojo : AbstractMojo() {
7474
* ```
7575
*/
7676
@Parameter(name = "converters")
77-
private var scalarConverters: Map<String, ScalarConverter> = emptyMap()
77+
private var converters: Map<String, ScalarConverter> = emptyMap()
7878

7979
/**
8080
* Directory file containing GraphQL queries, defaults to `src/main/resources`. Instead of specifying a directory you can
@@ -121,7 +121,7 @@ class GenerateClientMojo : AbstractMojo() {
121121
val config = GraphQLClientGeneratorConfig(
122122
packageName = packageName,
123123
allowDeprecated = allowDeprecatedFields,
124-
scalarTypeToConverterMapping = scalarConverters.map { (key, value) -> key to ScalarConverterMapping(value.type, value.converter) }.toMap()
124+
scalarTypeToConverterMapping = converters.map { (key, value) -> key to ScalarConverterMapping(value.type, value.converter) }.toMap()
125125
)
126126
generateClient(config, graphQLSchema, targetQueryFiles).forEach {
127127
it.writeTo(outputDirectory)

0 commit comments

Comments
 (0)