The first beta of the next major version of Apollo Kotlin is here!
While there still may be a few API changes before the stable release, we are getting close and this is a great time to try out the new version and report any issues you might find!
Many thanks to @baconz and @hbmartin for their awesome contributions to this release!
The GraphQL community is working hard at making it easier to work with nullability in GraphQL.
In Apollo Kotlin, it is now possible to change the nullability of fields and list elements at the schema level using schema extensions. This is useful if you believe the schema made a field nullable for error reasons only and you don't want to handle those errors. In these cases, the whole query will return as an error.
Given the following SDL:
# schema.graphqls
type Query {
random: Int
list: [String]
required: Int!
}
You can extend it like so:
# extra.graphqls
extend type Query {
# make random non-nullable
random: Int!
# make list and list items non-nullable
list: [String!]!
# make required nullable
required: Int
# add a new field
new: Float
}
generateMethods option to control which model methods are generated (#5212)By default all Kotlin models, operations, fragments, and input objects are generated as data classes. This means that the Kotlin compiler will
auto-generate toString, equals hashCode, copy and componentN. If you don't think you need all of those
methods, and/or you are worried about the size of the generated code, you can now choose which methods to generate with the generateMethods option:
apollo {
service("service") {
// Generates equals/hashCode
generateMethods.set(listOf("equalsHashCode"))
// Also generates toString, equals, and hashcode
generateMethods.set(listOf("equalsHashCode", "toString"))
// Only generates copy
generateMethods.set(listOf("copy"))
// Generates data classes (the default)
generateMethods.set(listOf("dataClass"))
}
}
Enum.values() is no longer recommended when using Kotlin 1.9+ and the generated code now uses entries instead (#5208)Optional<V>.getOrThrow() when V is nullable (#5192)useV3ExceptionHandling only throws when there are no errors populated (#5231)urlEncode algorithm (#5234)keyFields on non-existent fields (#5215)mergeExtensions and toFullSchemaGQLDocument (#5162)Optional<V>.getOrThrow() when V is nullable (#5192)registerOperations {} (#5196)generateMethods options to control which methods are generated on "data" classes (#5212)Fetched April 11, 2026