

When selecting a field whose type is nullable in the schema, the corresponding field in the generated Kotlin model will also be nullable.

Null safety on fieldsĪpollo Kotlin generates models based on your project’s GraphQL operations and the type information found in the schema. Let’s look at a few ways the library deals with nullability. In fact, nullability is one of the key features of GraphQL, allowing API authors to clearly specify which fields of a type are nullable.Īs for Kotlin, the language supports nullability in its type system, significantly reducing the risk for errors – for example assigning a potentially null value to a non-nullable field won’t even compile!Īt the intersection of these two worlds lies Apollo Kotlin, the GraphQL typesafe client library for Kotlin.

Mistake or not, null is here to stay and there are ways to coexist peacefully! The concept of null is sometimes called a “ billion dollar mistake”.
