Releases: apollographql/apollo-kotlin
v2.2.0
Summary
This version, amongst other things, contains RxJava3 support, a new way to register ApolloInterceptor
with factories and makes it easier to download your schema.json
from the command line. Starting with this version, releases are published on Maven Central in addition to Jcenter.
RxJava3 support (#2304)
Version 2.2.0 includes support for RxJava3. To use it, add the dependency to your Gradle file:
// RxJava3 support
implementation("com.apollographql.apollo:apollo-rx3-support:x.y.z")
The dependency contains static and extension methods to convert ApolloCall
, ApolloSubscriptionCall
, etc... to their RxJava3 counterparts.
For an exemple, to convert an ApolloCall
to an Observable
:
Java:
// Create a query object
EpisodeHeroName query = EpisodeHeroName.builder().episode(Episode.EMPIRE).build();
// Create an ApolloCall object
ApolloCall<EpisodeHeroName.Data> apolloCall = apolloClient.query(query);
// RxJava3 Observable
Observable<Response<EpisodeHeroName.Data>> observable3 = Rx3Apollo.from(apolloCall);
Kotlin:
// Create a query object
val query = EpisodeHeroNameQuery(episode = Episode.EMPIRE.toInput())
// Directly create Observable with Kotlin extension
val observable = apolloClient.rxQuery(query)
You can read more in the dedicated section of the documentation.
ApolloClient.applicationInterceptorFactories() (#2302)
ApolloInterceptors
added with ApolloClient.applicationInterceptor()
were only created once for the lifetime of the ApolloClient
so the same interceptor was always disposed. If you need your interceptor to start with a new state for each call, you can use ApolloInterceptorFactory
that will create a new interceptor for each new call.
Simplified downloadApolloSchema task usage from the command line (#2321)
Using the downloadApolloSchema
task from the command line is now easier:
# Instead of using properties:
./gradlew downloadApolloSchema -Pcom.apollographql.apollo.endpoint=https://your.graphql.endpoint \
-Pcom.apollographql.apollo.schema=src/main/graphql/com/example/schema.json
# You can now use `--endpoint` and `--schema`:
./gradlew downloadApolloSchema --endpoint=https://your.graphql.endpoint --schema=app/src/main/graphql/com/example/schema.json
Fixes
- Change constructor visibility for WebSocketSubscribtionTransport (#2348)
- [Runtime] fix AbstractMethodError due to @JvmSynthetic (#2349)
- Fix issue with query root level fragment support. (#2344)
- Add check for missing selection set for object types. (#2344)
- [Subscriptions] make a copy of the list to avoid ConcurrentModificationException (#2332)
- [Gradle Plugin] Use relative strings for the rootFolder input property so as not to break cacheability (#2294)
- [Build] release artifacts on maven central (#1130)
Internal changes
v2.1.0
Important changes
The normalized cache will not store partial response data anymore if the response contains errors (#2281). This is to avoid storing inconsistent data. Make sure that your code doesn't rely on this behaviour before upgrading.
New features
- It is now possible to generate GraphQL enum types as sealed classes to retain their rawValue. (#2279)
For this, use the sealedClassesForEnumsMatching
gradle option:
// build.gradle.kts
apollo {
sealedClassesForEnumsMatching.set(listOf("SomeEnum", "OtherEnum"))
}
Fixes
- [Runtime] ApolloStore.write fragment crash on execute (#2289)
- [Plugin] Create the directory for the user if needed during the schemaDownload (#2283)
- [Cache] Prevent incorrect caching of partial responses with errors (#2281)
- [Runtime] Revert okhttp to 3.12 to continue supporting Android 4.4 (#2269)
- [Codegen] Improve performance of the codegen (#2257)
- [Plugin] Also take into account the root project when enforcing versions (#2254)
Internal changes
- [Tooling] enable checkstyle again (#2296)
- [Documentation] Reorganize docset (#2292)
- [Runtime] Fix wrong error message in CallState (#2290)
- [Codegen] Update codegen tests (#2260)
- [Multiplatform] Make Execution context more Kotlin coroutine context idiomatic (#2258)
- [Multiplatform] Kotlin runtime initial structure (#2256)
- [Multiplatform] Introduce GraphQL execution context (#2248)
v2.0.3
v2.0.2
Important Fixes
Since version 2.0.0, the normalized cache could behave unpredictably when trying to update a CacheKey:
- Fix issue with sql cache not updated for the same CacheKey (#2245)
Internal changes
- Fix issues with Kotlin Multiplatform setup (#2238)
- Make sqlite module multiplatform Component: Kotlin MPP (#2234)
- Migrate Transaction and EvictionPolicy to Kotlin (#2144)
New features
There's now a shiny Swift UI demo app using Kotlin multiplatform models:
v2.0.1
New features
You can now add comments to your .graphql
queries.
For an example:
# This is a sample query to fetch hero name
# that demonstrates Java / Kotlin docs generations
# for query data model
query TestQuery {
...
}
Will produce somthing like:
/**
* This is a sample query to fetch hero name
* that demonstrates Java / Kotlin docs generations
* for query data model
*/
@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName",
"RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter")
class TestQuery : Query<TestQuery.Data, TestQuery.Data, Operation.Variables> {
Bug Fixes
- Make sure generated code do not produce warnings (#2219)
- Migrate Transaction and EvictionPolicy to Kotlin (#2144)
- Fix eager
asFlow()
completion (#2214) - Take nullity into account to generate correct code (#2213)
- Add missing Java/Kotlin Docs generation for generated classes (#2210)
Internal Changes
v2.0.0
Important Changes
Kotlin Multiplatform
We are really excited to announce that with this release it is possible to build Kotlin Multiplatform apps with Apollo. The supported targets are Android / iOS / JVM. Currently only apollo-api
module supports Kotlin Multiplatform. It is enough to use the generated code for preparing request body for Http calls and parse the response body.
- Checkout samples/multiplatform for sample application.
- Checkout multiplatform for details.
- Checkout no-runtime for usage of the apollo-api.
This is a backward compatible change for existing users. Please keep in mind that it will bring Kotlin standard library as a transitive dependency.
Side effect changes of Kotlin migration:
- Some primitive types like
Boolean
s may be unboxed where appropriate - Classes and functions are
final
unless they are intentionally marked asopen
- Kotlin-stdlib is added as a transitive dependency
- Jvm target version is now 1.8
- Gradle 6.x recommended. In 5.x, Gradle Metadata needs to be enabled by putting this into settings.gradle
enableFeaturePreview("GRADLE_METADATA")
Okio and OkHttp migration
During Kotlin Multiplatform integration, Okio and OkHttp are migrated to their latest major versions to make use of their Kotlin support.
Okio is upgraded to 2.4.3 and OkHttp is upgraded to 4.4.0
Note: If you explicitly depend on these libraries, it would be recommended to do major version upgrade of this libraries first before upgrading Apollo.
Both of them are binary compatible for Java users. There are some source incompatible changes for Kotlin users. Please use Code Cleanup
feature of IntelliJ / Android Studio to automatically handle the migration. More info can be found here: https://square.github.io/okhttp/upgrading_to_okhttp_4/
Update Okio and Okhttp (#2054)
New Normalized Cache Modules
For in-memory LruNormalizedCache
users, no change required since apollo-runtime
brings it as transitive dependency. It is still recommended adding the following dependency explicitly: implementation("com.apollographql.apollo:apollo-normalized-cache:x.y.z")
Apollo normalized cache module (#2142)
SqlNormalizedCache
is moved to its own module. If you added apollo-android-support
for disk cache, replace it with new dependency.
// Replace:
implementation("com.apollographql.apollo:apollo-android-support:x.y.z")
// With:
implementation("com.apollographql.apollo:apollo-normalized-cache-sqlite:2.0.0")
ApolloSqlHelper
is deprecated. Instantiate SqlNormalizedCacheFactory
class with same arguments instead.
// Replace:
val apolloSqlHelper = ApolloSqlHelper.create(context, "db_name")
val cacheFactory = SqlNormalizedCacheFactory(apolloSqlHelper)
// With:
val cacheFactory = SqlNormalizedCacheFactory(context, name = "db_name")
Replace legacy Android SQL with SqlDelight (#2158)
Deprecated Gradle Plugin is removed
The deprecated Gradle Plugin is now removed. Please refer to migration guide from previous releases before upgrading to 2.0
https://www.apollographql.com/docs/android/essentials/migration/#gradle-plugin-changes
Bug-fixes
- Suppress raw type warning in generated code (#2149)
- Fix issue with long query name generates bad formatted kotlin code (#2153)
- Fix an issue where removing graphql files does not remove the generated files (#2170)
- Fix
asFlow()
leak (#2175) - Put special KotlinPoet character to avoid broken wrapped code (#2190)
Kotlin Multiplatform Support
- Migrate Http cache api module to kotlin (#2051)
- Migrate Utils to kotlin (#2052)
- Refactor
ScalarType
(#2063) - Add iOS targets to API module (#2070)
- fix KMP artifacts (#2084)
- Convert top level api classes to Kotlin (#2021)
- Convert bunch of internal classes to Kotlin (#2028)
- Convert generic reader / writer Json classes to Kotlin (#2042)
- Convert OperationDataJsonSerializer to Kotlin by keeping existing Java api compatible. (#2050)
- Migrate logger to Kotlin (#2047)
- Convert next portion of api module files to Kotlin (#2044)
- Remove redundant supplier class and use Kotlin Function0 (#2059)
- Introduce Kotlin Multiplatform into apollo-api module (#2062)
- Fix publish task to cover Kotlin MPP (#2067)
- Some Kotlin MPP publication fixes (#2072)
- [Gradle Plugin] Support Kotlin multiplatform (#2120)
- Kotlin Multiplatform Sample (#2136)
- More Kotlin in normalized-cache (#2151)
- Migrate some normalized cache classes (#2148)
- Generate 'composeRequestBody' to encode GraphQL POST request payload (#2150)
- Add overloaded constructors for SqlNormalizedCacheFactory (#2189)
- Fix some of the dependency issues (#2168)
- Enable support for generics Objective-C interop (#2174)
- KMP sample: coroutines in common code (#2160)
- Generate overloaded parse method for ByteString (#2178)
- Fix compat issues on iOS target (#2177)
- Replace DetachedObjectGraph wrapper with stable ref. (#2198)
Clean up / Maintenance
- Remove apollo-gradle-plugin-deprecated (#2015)
- Fix deeplink to plugin config (#2056)
- bump gradle version to 6.2.2 (#2085)
- Update agp to 3.6 (#2088)
- Move to GitHub actions (#2091)
- Avoid doc duplication by using README.md on gatsby as well (#2053)
- Expose per repo publishing tasks (#2094)
- update Releasing.md (#2101)
- Updated Coroutines documentation with new extensions, removed depreciated extensions. (#2105)
- Silence sdkmanager (#2113)
- Move migration guide (#2114)
- Move getting started to top level (#2118)
- Add contribution instructions to README (#2110)
- Skip CI checks if the changes are only for documentations (#2115)
- fix tag detection (#2123)
- Move test class back into test sources (#2147)
- Add full exceptions for better error output on CI (#2155)
- Update docs for 2.0.0 release (#2169)
- Remove some deprecated declarations and usages for 2.0 (#2161)
- Update maven publishing (#2172)
- bump the plugin-publish version. (#2195)
- Make kotlin-sample project use generated Kotlin models (#2196
External Contributions
Thanks @ralphie9224 @zachburt05 @odlund @zhuhaow @lwasyl @SubhrajyotiSen for contributions
v1.4.5
Bug Fixes
- Suppress raw type warning in generated code (#2149)
- Fix issue with long query name generates bad formatted kotlin code (#2153)
- Fix an issue where removing graphql files does not remove the generated files (#2170)
- Fix
asFlow()
leak (#2175) - Put special KotlinPoet character to avoid broken wrapped code (#2190)
v1.4.4
v1.4.3
v1.4.2
Note: We had maven publish issue. Please use v1.4.3