github apollographql/apollo-kotlin v3.0.0-rc01

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

This version is the release candidate for Apollo Android 3 🚀. Please try it and report any issues, we'll fix them urgently.

There is documentation and a migration guide. More details are coming soon. In a nutshell, Apollo Android 3 brings, amongst other things:

  • coroutine APIs for easier concurrency
  • multiplatform support makes it possible to run the same code on Android, JS, iOS, MacOS and linux
  • responseBased codegen is a new optional codegen that models fragments as interfaces
  • SQLite batching makes reading from the SQLite cache significantly faster
  • Test builders offer a simple APIs to build fake models for your tests
  • The @typePolicy and @fieldPolicy directives make it easier to define your cache ids at compile time
  • The @nonnull directive catches null values at parsing time, so you don't have to deal with them in your UI code

Compared to beta05, this version changes the default value of generateOptionalOperationVariables, is compatible with Gradle configuration cache and fixes a few other issues.

⚙️ API changes

Optional operation variables (#3648) (breaking)

The default value for the generateOptionalOperationVariables config is now true.

What this means:

  • By default, operations with nullable variables will be generated with Optional parameters
  • You will need to wrap your parameters at the call site

For instance:

query GetTodos($first: Int, $offset: Int) {
  todos(first: $first, offset: $offset) {
    ...Todo
  }
}
// Before
val query = GetTodosQuery(100, null)

// After
val query = GetTodosQuery(Optional.Present(100), Optional.Absent)
  • If you prefer, you can set generateOptionalOperationVariables to false to generate non-optional parameters globally
  • This can also be controlled on individual variables with the @optional directive
  • More information about this can be found here

We think this change will make more sense to the majority of users (and is consistent with Apollo Android v2's behavior) even though it may be more verbose, which is why it is possible to change the behavior via the generateOptionalOperationVariables config.

To keep the beta05 behavior, set generateOptionalOperationVariables to false in your Gradle configuration:

apollo {
  generateOptionalOperationVariables.set(false)
}

ApolloClient.Builder improvements (#3647)

You can now pass WebSocket related options to the ApolloClient.Builder directly (previously this would have been done via NetworkTransport):

// Before
val apolloClient = ApolloClient.Builder()
    // (...)
    .subscriptionNetworkTransport(WebSocketNetworkTransport(
        serverUrl = "https://example.com/graphql",
        idleTimeoutMillis = 1000L,
        wsProtocol = SubscriptionWsProtocol.Factory()
    ))
    .build()

// After
val apolloClient = ApolloClient.Builder()
    // (...)
    .wsProtocol(SubscriptionWsProtocol.Factory())
    .webSocketIdleTimeoutMillis(1000L)
    .build()

Upgrade to OkHttp 4 (#3653) (breaking)

This version upgrades OkHttp to 4.9.3 (from 3.12.11). This means Apollo Android now requires Android apiLevel 21+. As OkHttp 3 enters end of life at the end of the year and the vast majority of devices now support apiLevel 21, we felt this was a reasonable upgrade.

🪲 Bug fixes

  • Fixed an issue where it was not possible to restart a websocket after a network error (#3646)
  • Fixed an issue where Android Java projects could not use the Apollo Gradle plugin (#3652)

👷 All Changes

  • Update a few dependencies (#3653)
  • Fix Android Java projects (#3652)
  • Expose more configuration options on ApolloClient.Builder (#3647)
  • Fix restarting a websocket after a network error (#3646)
  • Change optional default value (#3648)
  • Fix configuration cache (#3645)

Don't miss a new apollo-kotlin release

NewReleases is sending notifications on new releases.