diego-gomez-olvera
11/28/2025, 3:36 PMApolloResponse will evolve to adopt it, and I would like to minimize the effort for the next migration. Of course it's very early to tell and maybe it's complicated from the Java interoperability perspective, but initially looking at the error handling, they seem pretty interestingmbonnin
11/28/2025, 3:41 PMmbonnin
11/28/2025, 3:41 PMmbonnin
11/28/2025, 3:41 PMmbonnin
11/28/2025, 3:42 PMmbonnin
11/28/2025, 3:42 PMmbonnin
11/28/2025, 3:44 PMdiego-gomez-olvera
11/28/2025, 3:46 PM- Full response
- Partial response + errors
- ApolloException
- ApolloException + errorsmbonnin
11/28/2025, 3:47 PMApolloException + errorsThat one is not possible
diego-gomez-olvera
11/28/2025, 3:47 PMmbonnin
11/28/2025, 3:47 PMmbonnin
11/28/2025, 3:48 PMmbonnin
11/28/2025, 3:48 PMmbonnin
11/28/2025, 3:49 PMmbonnin
11/28/2025, 3:49 PM@catch allows you to handle the errors in the querymbonnin
11/28/2025, 3:50 PM@catchByDefault(to: THROW) and never have to check .errors everdiego-gomez-olvera
11/28/2025, 3:51 PMdiego-gomez-olvera
11/28/2025, 3:51 PMmbonnin
11/28/2025, 3:51 PMmbonnin
11/28/2025, 3:52 PMmbonnin
11/28/2025, 3:52 PM@catch to change some of your fields from T to FieldResult<T>mbonnin
11/28/2025, 3:53 PMmbonnin
11/28/2025, 3:53 PMStylianos Gakis
11/28/2025, 3:55 PMdiego-gomez-olvera
11/28/2025, 3:58 PMdiego-gomez-olvera
11/28/2025, 4:06 PMsealed class ServerResult<T> {
data class Valid<T : Any>(
val result: T,
val errors: List<Error>?,
) : ServerResult<T>()
data class Invalid<T>(
val errors: List<Error>,
) : ServerResult<T>()
class Failure<T>(
val exception: ApolloException,
) : ServerResult<T>()
}diego-gomez-olvera
11/28/2025, 4:12 PMmbonnin
11/28/2025, 4:18 PMValid, Partial and Failurembonnin
11/28/2025, 4:19 PMInvalid up there isn't super useful I think?diego-gomez-olvera
11/28/2025, 4:19 PMInvalid I am thinking of the row
A GraphQL request error happened or a Graph field error bubbled up.mbonnin
11/28/2025, 4:19 PMValid if you put errors in Validmbonnin
11/28/2025, 4:20 PMValid and Invalid?diego-gomez-olvera
11/28/2025, 4:20 PMValid is that T has a valuembonnin
11/28/2025, 4:20 PMmbonnin
11/28/2025, 4:21 PMFailure thoughmbonnin
11/28/2025, 4:21 PMmbonnin
11/28/2025, 4:22 PMdiego-gomez-olvera
11/28/2025, 4:23 PMInvalid : Report either exception or errorsmbonnin
11/28/2025, 4:24 PMdiego-gomez-olvera
11/28/2025, 4:36 PMsealed class ServerResult<T> {
data class Valid<T : Any>(
val result: T,
val errors: List<Error>?,
) : ServerResult<T>()
sealed class Invalid<T> : ServerResult<T>()
class GraphFieldError<T>(
val errors: List<Error>,
) : Invalid<T>()
class RequestFailure<T>(
val exception: ApolloException,
) : Invalid<T>()
}
but it will be more practical to merge the Invalid
sealed class ServerResult<T> {
data class Valid<T : Any>(
val result: T,
val errors: List<Error>?,
) : ServerResult<T>()
class Invalid<T>(
val errors: List<Error>?,
val exception: ApolloException?,
) : ServerResult<T>()
}
if it always has the same treatmentmbonnin
11/28/2025, 4:40 PMmbonnin
11/28/2025, 4:40 PMerrors and exception are exclusive in the Invalid casembonnin
11/28/2025, 4:41 PMmbonnin
11/28/2025, 4:42 PMsealed interface Result
sealed class Valid: Result
sealed interface Invalid Result
sealed class RequestError: Invalid
sealed class IOError: Invaliddiego-gomez-olvera
11/28/2025, 4:42 PMmbonnin
11/28/2025, 4:42 PMdiego-gomez-olvera
11/28/2025, 4:43 PMdiego-gomez-olvera
12/18/2025, 11:17 AMdiego-gomez-olvera
12/18/2025, 11:48 AMdiego-gomez-olvera
12/18/2025, 2:20 PMError types cannot have superclasses, superinterfaces, or generic parameters. Essentially, error types present a new flat hierarchy in the Kotlin type system. It's needed to form only disjoint unions.