github apollographql/apollo-kotlin v2.2.0

latest releases: v4.1.0, v4.0.1, v4.0.0...
4 years ago

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

  • Provide base websocket abstraction (#2311)
  • [Kotlin Runtime] Add BearerTokenInterceptor (#2298)
  • [Tooling] enable checkstyle again (#2296)
  • Fix a small issue in sample (#2308)

Don't miss a new apollo-kotlin release

NewReleases is sending notifications on new releases.