@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
- NEW: Promote experimental websockets to stable by @martinbonnin in #6774
- NEW: Add
@catchsupport for responseBased codegen by @martinbonnin in #6697 - NEW: Support descriptions on variable definitions by @BoD in #6699
- NEW: Support Android Gradle Plugin 9 (AGP9) by @martinbonnin in #6703
- NEW: Add
Service.issueSeverity()by @martinbonnin in #6731 - NEW: Add HTTP caching using OkHttp cacheUrlOverride by @martinbonnin in #6739
- NEW: Implement
@deferand@streamas ofincremental/v0.2by @BoD in #6331 - NEW: Add
ApolloRequest.Builder.url(String)by @martinbonnin in #6758 - NEW: Add a specific issue type for fragment cycles by @martinbonnin in #6759
- NEW: Add
ApolloInterceptor.InsertionPointto control where the interceptors are added by @martinbonnin in #6761 - NEW: Introduce
RetryStrategyby @martinbonnin in #6764 - FIX: Make
Optional.Absentadata objectby @JakeWharton in #6686 - FIX: Use regular
if/elseto avoidIntboxing by @JakeWharton in #6688 - FIX: Remove kotlin-node dependency by @martinbonnin in #6708
- FIX: Do not check already checked fragments in checkCapitalizedFields by @BoD in #6718
- FIX: Pretty-print operation manifest by @BoD in #6720
- FIX: Allow empty deprecationReasons by @martinbonnin in #6729
- FIX: Fix IndexOutOfBoundsException in keyFields validation by @BoD in #6748
- FIX: Allow multiple success responses in ApolloCall.execute() by @BoD in #6772
- FIX: Restore JsonReader state if a field throws in-flight by @martinbonnin in #6775
- FIX: Exclude auto-imported cache related directives when the Apollo cache plugin is present by @BoD in #6766
- FIX: fix a timeout leak in the default HttpEngine by @martinbonnin in #6762
- DOCS: add linuxX64 as supported for apollo-runtime by @hrach in #6689
- DOCS: Update
@deferdocumentation by @calvincestari in #6751 - UPDATE: Bump KGP to 2.2.20 by @BoD in #6716