github apollographql/apollo-kotlin v5.0.0-alpha.3

8 hours ago

@stream support

You may now use @stream to stream list responses from a compatible server.

To do this, opt in support for the incremental:v0.2 protocol:

val apolloClient = ApolloClient.Builder()
    .networkTransport(
        HttpNetworkTransport.Builder()
            .serverUrl("http://example.com/graphql")
            .incrementalDeliveryProtocol(IncrementalDeliveryProtocol.V0_2)
            .build()
    )
    .build()

Using @defer and @stream will stay opt-in until the RFC is merged.

Experimental WebSockets are stable

The experimental WebSockets are promoted to stable. In particular, the request url may now be changed in interceptors. This can be used together with RetryStrategy to change the authentication parameters when retrying a subscription. The previous implementation (using the com.apollographql.apollo.ws package name) is now deprecated.

Read more in the migration guide.

Leveraging OkHttp cache

You can now use OkHttp cacheUrlOverride() to cache POST requests.

To do so, configure a cache on your OkHttpClient and use enablePostCaching:

val apolloClient = ApolloClient.Builder()
    .networkTransport(
        HttpNetworkTransport.Builder()
            // Enable POST caching
            .httpRequestComposer(DefaultHttpRequestComposer(serverUrl = mockServer.url(), enablePostCaching = true))
            .httpEngine(
                DefaultHttpEngine {
                  OkHttpClient.Builder()
                      .cache(directory = File(application.cacheDir, "http_cache"), maxSize = 10_000_000)
                      .build()
                }
            )
            .build()
    )
    .build()

The existing apollo-http-cache artifacts have been deprecated. Moving forward, leveraging the cache of existing clients (OkHttp, Ktor, etc...) is the recommended way to do caching at the HTTP layer.

Read more in the migration guide.

AGP9 support

The Gradle plugin now works with AGP 9 and the com.android.kotlin.multiplatform.library plugin.

Service.issueSeverity()

You may now control the severity of issues found by the compiler in your Gradle scripts:

service("service") { 
  packageName.set("com.example")
  // Do not fail the build on unused fragments
  // Valid values are the names of the subclasses of `com.apollographql.apollo.ast.Issue`
  issueSeverity("UnusedFragment", "warn") 
}

👷‍♂️ All changes

Don't miss a new apollo-kotlin release

NewReleases is sending notifications on new releases.