commonMain.com.apollographql.apollo.api.internal.ResponseReader.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.ResponseField
import com.apollographql.apollo.api.ScalarType
/*
* ResponseReader is an abstraction for reading GraphQL fields.
*/
interface ResponseReader {
fun readString(field: ResponseField): String?
fun readInt(field: ResponseField): Int?
fun readLong(field: ResponseField): Long?
fun readDouble(field: ResponseField): Double?
fun readBoolean(field: ResponseField): Boolean?
fun readObject(field: ResponseField, objectReader: ObjectReader): T?
fun readObject(field: ResponseField, block: (ResponseReader) -> T): T? {
return readObject(field, object : ObjectReader {
override fun read(reader: ResponseReader): T {
return block(reader)
}
})
}
fun readFragment(field: ResponseField, objectReader: ObjectReader): T?
fun readFragment(field: ResponseField, block: (ResponseReader) -> T): T? {
return readFragment(field, object : ObjectReader {
override fun read(reader: ResponseReader): T {
return block(reader)
}
})
}
fun readList(field: ResponseField, listReader: ListReader): List?
fun readList(field: ResponseField, block: (ListItemReader) -> T): List? {
return readList(field, object : ListReader {
override fun read(reader: ListItemReader): T {
return block(reader)
}
})
}
fun readCustomType(field: ResponseField.CustomTypeField): T?
interface ObjectReader {
fun read(reader: ResponseReader): T
}
interface ListReader {
fun read(reader: ListItemReader): T
}
interface ListItemReader {
fun readString(): String
fun readInt(): Int
fun readLong(): Long
fun readDouble(): Double
fun readBoolean(): Boolean
fun readCustomType(scalarType: ScalarType): T
fun readObject(objectReader: ObjectReader): T
fun readObject(block: (ResponseReader) -> T): T {
return readObject(object : ObjectReader {
override fun read(reader: ResponseReader): T {
return block(reader)
}
})
}
fun readList(listReader: ListReader): List
fun readList(block: (ListItemReader) -> T): List {
return readList(object : ListReader {
override fun read(reader: ListItemReader): T {
return block(reader)
}
})
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy