Introduction to Apollo Android
A strongly-typed, caching GraphQL client for the JVM, Android and Kotlin multiplatform
Apollo Android is a GraphQL client that generates Java and Kotlin models from GraphQL queries. These models give you a type-safe API to work with GraphQL servers. Apollo helps you keep your GraphQL query statements together, organized, and easy to access.
This library is designed primarily with Android in mind, but you can use it in any Java/Kotlin app.
Features
- Java and Kotlin code generation
- Queries, Mutations and Subscriptions
- Reflection-free parsing of responses
- HTTP cache
- Normalized cache
- File uploads
- Custom scalar types
- Reactive bindings for: RxJava2, RxJava3, Coroutines, Reactor and Mutiny
Getting started
If you are new to GraphQL, check out
If you'd like to add Apollo Android to an existing project:
- Get started with Kotlinshows how to add Apollo Android to a Kotlin project.
- Get started with Javashows how to add Apollo Android to a Java project.
- Get started with Multiplatform (Experimental)shows how to add Apollo Android to a Multiplatform project. This is still under heavy development and APIs may change without warning.
Advanced topics
Check
IntelliJ Plugin
The .graphql
files. You can create a .graphqlconfig
Releases
Check the
Releases are hosted on
plugins {id("com.apollographql.apollo").version("x.y.z")}repositories {mavenCentral()}dependencies {implementation("com.apollographql.apollo:apollo-runtime:x.y.z")// optional: if you want to use the normalized cacheimplementation("com.apollographql.apollo:apollo-normalized-cache-sqlite:x.y.z")// optional: for coroutines supportimplementation("com.apollographql.apollo:apollo-coroutines-support:x.y.z")// optional: for Mutiny supportimplementation("com.apollographql.apollo:apollo-mutiny-support:x.y.z")// optional: for Reactor supportimplementation("com.apollographql.apollo:apollo-reactor-support:x.y.z")// optional: for RxJava3 supportimplementation("com.apollographql.apollo:apollo-rx3-support:x.y.z")// optional: Most of apollo-android does not depend on Android in practice and runs on any JVM or on Kotlin native. apollo-android-support contains a few Android-only helper classes. For an example to send logs to logcat or run callbacks on the main thread.implementation("com.apollographql.apollo:apollo-android-support:x.y.z")// optional: if you just want the generated models and parsers and write your own HTTP code/cache code, you can remove apollo-runtime// and use apollo-api insteadimplementation("com.apollographql.apollo:apollo-api:x.y.z")}
Snapshots
Latest development changes are available in Sonatype's snapshots repository:
repositories {maven {url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")}}
Requirements
Apollo Android runs on the following platforms:
- Android API level 15+
- JDK 8+
- iOS 13+
Contributing
If you'd like to contribute, please see
Community integrations
- If you're using the Mavenbuild tool,https://github.com/aoudiamoncef/apollo-client-maven-pluginis a Maven plugin that calls the Apollo Android compiler to generate your Java/Kotlin sources.
Additional resources
- MortyComposeKMM: A Kotlin Multiplatform Github template using Apollo Android, SwiftUI and Jetpack Compose.
- A journey to Kotlin multiplatform: how the project was moved to Kotlin multiplatform, talk given at Kotliners in June 2020.
- #125, Fragmented Podcast: Why's and How's about Apollo Android and the entire journey.
- GraphQL.orgfor an introduction and reference to GraphQL itself.
- apollographql.comto learn about Apollo open-source and commercial tools.
- The Apollo blogfor long-form articles about GraphQL, feature announcements for Apollo, and guest articles from the community.
- The Apollo Twitter accountfor in-the-moment news.
Who is Apollo?
- Apollo Studio– A free, end-to-end platform for managing your GraphQL lifecycle. Track your GraphQL schemas in a hosted registry to create a source of truth for everything in your graph. Studio provides an IDE (Apollo Explorer) so you can explore data, collaborate on queries, observe usage, and safely make schema changes.
- Apollo Federation– The industry-standard open architecture for building a distributed graph. Use Apollo’s open-source gateway to compose a unified graph from multiple subgraphs, determine a query plan, and route requests across your services.
- Apollo Client– The most popular GraphQL client for the web. Apollo also builds and maintainsApollo iOSandApollo Android.
- Apollo Server– A production-ready JavaScript GraphQL server that connects to any microservice, API, or database. Compatible with all popular JavaScript frameworks and deployable in serverless environments.
Learn how to build with Apollo
Check out the