
SSE network transport enabling GraphQL subscriptions over graphql-sse, with configurable headers, reconnection policy, and pluggable HTTP client optimized for streaming.
A Server-Sent Events (text/event-stream) NetworkTransport for Apollo Kotlin,
enabling GraphQL subscriptions over the graphql-sse protocol.
Kotlin Multiplatform: JVM, Android, iosArm64, iosSimulatorArm64, iosX64, macosArm64.
// build.gradle.kts
dependencies {
implementation("net.avianlabs.apollo:apollo-sse:0.1.0")
}import com.apollographql.apollo.ApolloClient
import net.avianlabs.apollo.sse.SseNetworkTransport
val sseTransport = SseNetworkTransport.Builder()
.serverUrl("https://example.com/graphql")
.addHeader("Authorization", "Bearer $token")
.reconnectWhen { error, attempt ->
// Return true to retry, false to surface the error to the subscription
attempt < 5
}
.build()
val apolloClient = ApolloClient.Builder()
.httpServerUrl("https://example.com/graphql")
.subscriptionNetworkTransport(sseTransport)
.build()If you bring your own OkHttpClient via the okHttpClient(...) extension, configure
it for streaming — most importantly, disable the read timeout:
val client = OkHttpClient.Builder()
.connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(0, TimeUnit.MILLISECONDS) // no read timeout for long-lived SSE streams
.build()
val transport = SseNetworkTransport.Builder()
.serverUrl("https://example.com/graphql")
.okHttpClient(client)
.build()If you don't supply an engine, the platform default is used (OkHttp on JVM/Android,
NSURLSession on Apple targets — whatever DefaultHttpEngine resolves
to on your target).
| apollo-sse | Apollo Kotlin | Kotlin | JVM target |
|---|---|---|---|
| 0.1.x | 5.x | 2.3.x | 21 |
Apache 2.0. See LICENSE.
A Server-Sent Events (text/event-stream) NetworkTransport for Apollo Kotlin,
enabling GraphQL subscriptions over the graphql-sse protocol.
Kotlin Multiplatform: JVM, Android, iosArm64, iosSimulatorArm64, iosX64, macosArm64.
// build.gradle.kts
dependencies {
implementation("net.avianlabs.apollo:apollo-sse:0.1.0")
}import com.apollographql.apollo.ApolloClient
import net.avianlabs.apollo.sse.SseNetworkTransport
val sseTransport = SseNetworkTransport.Builder()
.serverUrl("https://example.com/graphql")
.addHeader("Authorization", "Bearer $token")
.reconnectWhen { error, attempt ->
// Return true to retry, false to surface the error to the subscription
attempt < 5
}
.build()
val apolloClient = ApolloClient.Builder()
.httpServerUrl("https://example.com/graphql")
.subscriptionNetworkTransport(sseTransport)
.build()If you bring your own OkHttpClient via the okHttpClient(...) extension, configure
it for streaming — most importantly, disable the read timeout:
val client = OkHttpClient.Builder()
.connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(0, TimeUnit.MILLISECONDS) // no read timeout for long-lived SSE streams
.build()
val transport = SseNetworkTransport.Builder()
.serverUrl("https://example.com/graphql")
.okHttpClient(client)
.build()If you don't supply an engine, the platform default is used (OkHttp on JVM/Android,
NSURLSession on Apple targets — whatever DefaultHttpEngine resolves
to on your target).
| apollo-sse | Apollo Kotlin | Kotlin | JVM target |
|---|---|---|---|
| 0.1.x | 5.x | 2.3.x | 21 |
Apache 2.0. See LICENSE.