v1.3.0
Migration guide:
https://github.com/apollographql/apollo-android#migrating-to-13x
BREAKING-CHANGES:
This release introduces breaking changes to generated Kotlin models with inline fragments. Field inlineFragment
is no longer generated, for example:
data class Hero(
val __typename: String,
/**
* The name of the character
*/
val name: String,
val inlineFragment: HeroCharacter?
) {
val asHuman: AsHuman? = inlineFragment as? AsHuman
val asDroid: AsDroid? = inlineFragment as? AsDroid
...
data class Hero(
val __typename: String,
/**
* The name of the character
*/
val name: String,
val asHuman: AsHuman?,
val asDroid: AsDroid?
)
previous version of code generation wasn't quite correct, as there are cases when multiple inline fragments can be resolved for the same type. For example having this GraphQL interface hierarchy Character <- Hero <- Human
and this GraphQL query:
query {
character {
name
... on Hero { ... }
... on Human { ... }
}
}
both inline fragments AsHero
and AsHuman
must be resolved for character field with type Human
(due to the hierarchy Hero <- Human
). Previous version of generated model for character
resolves only first fragment AsHero
. New one - resolves both AsHero
and AsHuman
inline fragments.
Migration:
If you had this code to get access to the inline fragment before:
when (hero.inlineFragment) {
is Hero.AsHuman -> ...
is Hero.AsDroid -> ...
}
you should change it and check all declared inline fragment for nullability, as it's possible to have multiple fragments to be resolved :
if (hero.asHuman != null) {
...
}
if (hero.asDroid != null) {
...
}
Changelog:
toJson kotlin extension (#1922)
Generate Operation.Data toJson implementation (#1916)
Do not take into account sources set on ApolloExtension or Service for Test variants (#1913)
Add support of fragment with directives (#1912)
Promote incubating plugin (#1903)
Add support directives to inline fragments (#1891)
Singularization fixes (#1888)
Move IdlingResources to AndroidX libraries (#1878)
More clear project name for composite build Build Scripts (#1875)
Capitalize class name after singularize irregular word (#1870)
Generate default value for optional variables (#1869)
Remove transformed queries (#1859)
Add customizable persisted query id generation (#1849)
Provide a way to look at query generated operation output. (#1841)