Launch Apollo Studio

Get started with Java

Apollo Android 3 is available in alpha. It is still in active development, and we'd love for folks to test it out. See the v3 documentation and please report any issues!

Add the Gradle plugin

In your app Gradle file, apply the com.apollographql.apollo plugin:

Using the plugins DSL:

plugins {
  // ...

Or using the legacy syntax:

buildscript {
  // ...

apply plugin: "com.apollographql.apollo"

The plugin is hosted on the Gradle plugin portal, Jcenter and Maven Central.

Add the runtime dependencies

dependencies {

Download your schema.json file

Apollo Android requires your GraphQL server's schema as either an introspection or SDL schema. Usually, it's a schema.[graphqls|json|sdl] file. This section shows how to obtain a schema from your server using introspection.

Note: If you don't have a GraphQL server yet, you can use the server from the tutorial: https://apollo-fullstack-tutorial.herokuapp.com/graphql.

The Apollo Gradle plugin exposes a downloadApolloSchema task to help you obtain your schema. Provide this task your server's GraphQL endpoint and the output location for the schema.json file:

# Create a directory for your GraphQL files:
mkdir -p app/src/main/graphql/com/example/

# --schema is interpreted relative to the current working directory. This example
# assumes the root project directory and an Android app in `app`
./gradlew downloadApolloSchema \
  --endpoint="https://your.domain/graphql/endpoint" \

If your GraphQL endpoint requires authentication, you can pass custom HTTP headers:

./gradlew downloadApolloSchema \
  --endpoint="https://your.domain/graphql/endpoint" \
  --schema="app/src/main/graphql/com/example/schema.graphqls" \
  --header="Authorization: Bearer $TOKEN"

Add your query

Put your first GraphQL query in a .graphql file, in the same directory as your downloaded schema: app/src/main/graphql/com/example/LaunchDetails.graphql

query LaunchDetails($id:ID!) {
  launch(id: $id) {
    mission {

Now build your project, which will generate the models. Either click the green triangle in Android Studio or run the following:

./gradlew build

Executing your query

You use an instance of the ApolloClient class to interact with your server and cache.

To make a query using your generated models:

// First, create an `ApolloClient`
// Replace the serverUrl with your GraphQL endpoint
ApolloClient apolloClient = ApolloClient.builder()

// Then enqueue your query
apolloClient.query(new LaunchDetailsQuery("83"))
        .enqueue(new ApolloCall.Callback<LaunchDetailsQuery.Data>() {
            public void onResponse(@NotNull Response<LaunchDetailsQuery.Data> response) {
                Log.e("Apollo", "Launch site: " + response.getData().launch.site);

            public void onFailure(@NotNull ApolloException e) {
                Log.e("Apollo", "Error", e);

What's next

Edit on GitHub