else { if (response.data.video.title == null) { Text(text = "This video doesn't have a title yet") } else { Text(text = response.data.video.title) } } }
"video.title" }) { Error() // Can't display a video without a title } else { if (response.data.video.title != null) { Text(text = "This video does not have a title yet") } else { Text(text = response.data.video.title!!) } if (response.errors.any { it.path == "video.viewCount" }) { // Skip viewCount } else { Text(text = "${response.data.video.viewCount!!} + views") } } } Partial data
null if the video has just been uploaded """ title: String """ Number of times this video has been watched Never null unless there is an error """ viewCount: Int }
{ title # opt-in error handling viewCount @catch } } sealed interface Result<T> { class Success(val value: T): Result class Failure(val error: error): Result } Video( val title: String val viewCount: Result<Int> ) apollographql/apollo-kotlin/pull/5405