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 ofgenerateOptionalOperationVariables
, 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 nowtrue
.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
tofalse
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, setgenerateOptionalOperationVariables
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 viaNetworkTransport
):// 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
(from3.12.11
). This means Apollo Android now requires AndroidapiLevel
21
๐ +. As OkHttp 3 enters end of life at the end of the year and the vast majority of devices now supportapiLevel
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)