Home / Companies / Apollo / Blog / Post Details
Content Deep Dive

Nullability in GraphQL and Apollo Kotlin

Blog post from Apollo

Post Details
Company
Date Published
Author
Benoit Lubek
Word Count
1,408
Language
English
Hacker News Points
-
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.