commonMain.com.apollographql.apollo.api.internal.SimpleResponseReader.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apollo-api-jvm Show documentation
Show all versions of apollo-api-jvm Show documentation
Apollo GraphQL API classes
package com.apollographql.apollo.api.internal
import com.apollographql.apollo.api.BigDecimal
import com.apollographql.apollo.api.CustomTypeValue
import com.apollographql.apollo.api.Operation
import com.apollographql.apollo.api.ResponseField
import com.apollographql.apollo.api.ScalarType
import com.apollographql.apollo.api.ScalarTypeAdapters
import com.apollographql.apollo.api.toNumber
class SimpleResponseReader private constructor(
private val recordSet: Map,
private val variableValues: Map,
private val scalarTypeAdapters: ScalarTypeAdapters
) : ResponseReader {
constructor(
recordSet: Map,
variables: Operation.Variables,
scalarTypeAdapters: ScalarTypeAdapters
) : this(recordSet, variables.valueMap(), scalarTypeAdapters)
override fun readString(field: ResponseField): String? {
if (shouldSkip(field)) {
return null
}
val value = valueFor(recordSet, field)
return checkValue(field, value)
}
override fun readInt(field: ResponseField): Int? {
if (shouldSkip(field)) {
return null
}
val value = valueFor(recordSet, field)
checkValue(field, value)
return value?.toNumber()?.toInt()
}
override fun readLong(field: ResponseField): Long? {
if (shouldSkip(field)) {
return null
}
val value = valueFor(recordSet, field)
checkValue(field, value)
return value?.toNumber()?.toLong()
}
override fun readDouble(field: ResponseField): Double? {
if (shouldSkip(field)) {
return null
}
val value = valueFor(recordSet, field)
checkValue(field, value)
return value?.toNumber()?.toDouble()
}
override fun readBoolean(field: ResponseField): Boolean? {
if (shouldSkip(field)) {
return null
}
val value = valueFor(recordSet, field)
return checkValue(field, value)
}
override fun readObject(field: ResponseField, objectReader: ResponseReader.ObjectReader): T? {
if (shouldSkip(field)) {
return null
}
val value = valueFor
© 2015 - 2025 Weber Informatics LLC | Privacy Policy