Skip to content

Commit 44baaa6

Browse files
committed
Allow any type as response to account for batched array results from graphql
1 parent 3a3dc5a commit 44baaa6

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

templates/android/library/src/main/java/io/appwrite/Client.kt.twig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ class Client @JvmOverloads constructor(
230230
headers: Map<String, String> = mapOf(),
231231
params: Map<String, Any?> = mapOf(),
232232
responseType: Class<T>,
233-
converter: ((Map<String, Any,>) -> T)? = null
233+
converter: ((Any -> T)? = null
234234
): T {
235235
val filteredParams = params.filterValues { it != null }
236236

@@ -321,7 +321,7 @@ class Client @JvmOverloads constructor(
321321
headers: MutableMap<String, String>,
322322
params: MutableMap<String, Any?>,
323323
responseType: Class<T>,
324-
converter: ((Map<String, Any,>) -> T),
324+
converter: ((Any) -> T),
325325
paramName: String,
326326
idParamName: String? = null,
327327
onProgress: ((UploadProgress) -> Unit)? = null,
@@ -444,7 +444,7 @@ class Client @JvmOverloads constructor(
444444
private suspend fun <T> awaitResponse(
445445
request: Request,
446446
responseType: Class<T>,
447-
converter: ((Map<String, Any,>) -> T)? = null
447+
converter: ((Any) -> T)? = null
448448
) = suspendCancellableCoroutine<T> {
449449
http.newCall(request).enqueue(object : Callback {
450450
override fun onFailure(call: Call, e: IOException) {
@@ -505,9 +505,9 @@ class Client @JvmOverloads constructor(
505505
it.resume(true as T)
506506
return
507507
}
508-
val map = gson.fromJson<Map<String, Any>>(
508+
val map = gson.fromJson<Any>(
509509
body,
510-
object : TypeToken<Map<String, Any>>(){}.type
510+
object : TypeToken<Any>(){}.type
511511
)
512512
it.resume(
513513
converter?.invoke(map) ?: map as T

templates/android/library/src/main/java/io/appwrite/services/ServiceTemplate.kt.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ class {{ service.name | caseUcfirst }} : Service {
116116
{{ method.headers|map((header, key) => " \"#{key}\" to \"#{header}\"")|join(',\n')|raw }}
117117
)
118118
{% if method.responseModel %}
119-
val converter: (Map<String, Any>) -> {{ _self.resultType(sdk.namespace, method) }} = {
119+
val converter: (Any) -> {{ _self.resultType(sdk.namespace, method) }} = {
120120
{% if method.responseModel == 'any' %}
121121
it
122122
{% else %}
123-
{{ _self.resultType(sdk.namespace, method) }}.from(map = it)
123+
{{ _self.resultType(sdk.namespace, method) }}.from(map = it as Map<String, Any>)
124124
{% endif %}
125125
}
126126
{% endif %}

0 commit comments

Comments
 (0)