This project demonstrates GraphQL subscriptions working with WebAssembly (WasmJS) target in Apollo Kotlin. It uses a custom Apollo Kotlin build with WASM support that is automatically built from source in CI.
This was created as a demo for PR Link
- GraphQL Subscriptions working across all Kotlin Multiplatform targets including WasmJS
- Real-time communication between GraphQL server and clients using WebSockets
- Multiplatform GraphQL client implementation with Apollo Kotlin
- Cross-platform UI built with Compose Multiplatform
- CI/CD pipeline that builds Apollo Kotlin from source with WASM support
- Android - Native Android app
- iOS - Native iOS app
- Desktop - JVM desktop application (macOS, Windows, Linux)
- Web (WasmJS) - WebAssembly web application (requires custom Apollo build)
- Server - Ktor GraphQL server with subscription support
Ktor-based GraphQL server providing:
- GraphQL queries, mutations, and subscriptions
- WebSocket support for real-time subscriptions
- CORS configuration for cross-platform access
- GraphiQL playground at
/graphiql
Compose Multiplatform client application supporting:
- Android target
- iOS targets (iosX64, iosArm64, iosSimulatorArm64)
- Desktop (JVM) target
- Web (WasmJS) target - The main focus of this demo
Shared business logic and models used across all client platforms.
iOS-specific entry point and configuration for the native iOS application.
- JDK 17+ (required for Apollo Kotlin build)
- Android Studio (for Android builds)
- Xcode (for iOS builds, macOS only)
- Node.js (for web builds)
git clone https://github.com/your-username/apollo-kotlin-demo.git
cd apollo-kotlin-demoThis project uses Apollo Kotlin 5.0.0-alpha.local-SNAPSHOT with WASM support. The CI automatically:
- Builds Apollo Kotlin from source with the latest WASM support
- Publishes to local Maven repository
- Uses the fresh build for WasmJS compilation
For local development, you can either:
- Use the CI: Push changes and let GitHub Actions build everything
- Build Apollo locally: Follow the steps in
LOCAL_CI_SETUP.md
./gradlew :server:runThe server will start at http://localhost:8080
- GraphQL endpoint:
http://localhost:8080/graphql - GraphiQL playground:
http://localhost:8080/graphiql
./gradlew :composeApp:installDebug
# Or open in Android Studio and run./gradlew :composeApp:iosSimulatorArm64App
# Or open iosApp/iosApp.xcodeproj in Xcode./gradlew :composeApp:run./gradlew :composeApp:wasmJsBrowserDevelopmentRunAccess at http://localhost:8080 (different port from server)
The GraphQL server is deployed at: https://apollo-kotlin-demo.onrender.com/graphql
- Use this endpoint in clients to test without running the server locally
- GraphiQL playground: https://apollo-kotlin-demo.onrender.com/graphiql
Live WasmJS demo: https://aryapreetam.github.io/apollo-kotlin-demo
Pre-built executables will be available in the Releases section:(TBD)
- Android APK
- Desktop applications (macOS .dmg, Windows .msi, Linux .deb)
- iOS IPA (for testing on devices)
| web(wasmJs) | android | ios |
| desktop |
apollo-kotlin-demo-720p.mp4
Websockets with binary data(send/receive) in wasmJs:
apollo-kotlin-demo-with-binary_1080p.mov
- Server: Use
localhost:8080when testing locally - Android: Use your computer's IP address (e.g.,
192.168.1.xxx:8080) for device testing - iOS: Configure network permissions in
Info.plistfor local server access - Web: Served on a different port, but connects to GraphQL server on port 8080
./gradlew :composeApp:assembleRelease./gradlew :composeApp:packageDistributionForCurrentOS./gradlew :composeApp:wasmJsBrowserProductionWebpack- Start the server with
./gradlew :server:run - Open GraphiQL at
http://localhost:8080/graphiql - Test subscription:
subscription { stringListUpdates }
- Trigger updates with mutations:
mutation { addString(value: "Hello World") }
- Run any client and observe real-time updates
- β GraphQL Subscriptions on WasmJS (main contribution)
- β WebSocket communication across all platforms
- β Real-time UI updates with Compose Multiplatform
- β Cross-platform GraphQL client with Apollo Kotlin
- β Type-safe GraphQL operations generated from schema
This project serves as a demonstration for GraphQL subscriptions support in Apollo Kotlin's WasmJS target. Feel free to:
- Test the implementation
- Report issues
- Suggest improvements
- Use as reference for your own projects
This project is open source and available under the MIT License.