apollo-android v3.0.0-rc01 Release Notes

  • 2021-12-07

    ๐Ÿš€ 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

    0๏ธโƒฃ 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)

    0๏ธโƒฃ The default value for the generateOptionalOperationVariables config is now true.

    What this means:

    • 0๏ธโƒฃ 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)