Company
Date Published
Author
Benoit Lubek
Word count
1408
Language
English
Hacker News points
None

Summary

GraphQL and nullability coexist peacefully in Apollo Kotlin, a GraphQL typesafe client library for Kotlin. Nullability is supported through annotations such as `@nonnull`, which instruct the codegen to act as if fields were non-nullable. This feature is currently an RFC in the official GraphQL spec and will allow marking fields in queries as non-nullable with a new syntax. Apollo Kotlin also generates Java code, supporting nullability through annotations like `@Nullable` and wrapping nullable types in `Optional`. The library handles null vs absent values for input values and operation arguments, providing tools to deal with nullability and avoid costly `NullPointerExceptions`. By using Apollo Kotlin, developers can leverage the strong typing of GraphQL and Kotlin to handle nullability effectively.