In your app Gradle file, apply the
Using the plugins DSL:
Or using the legacy syntax:
The plugin is hosted on the Gradle plugin portal, Jcenter and Maven Central.
Apollo Android requires your GraphQL server's schema as a
schema.json file. You can obtain the contents of this file by running an introspection query on your server.
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
Always remember to replace
API_SECRET with the correct value that you copied from apito console.
Go to this page if you do not know where to find your api secrets for your project
- Create a directory for your GraphQL files:
- Add your
schema.jsonto the directory:
- Put your query in a
.graphqlfile, next to the schema:
- Build your project, this will generate the model
You use an instance of the
ApolloClient class to interact with your server and cache.
To make a query using your generated models: