Java Apollo Android
| Package name | Weekly Downloads | Version | License | Updated |
|---|---|---|---|---|
@graphql-codegen/java-apollo-android | Apr 19th, 2026 |
Installation
npm i -D @graphql-codegen/java-apollo-androidThis plugin and presets creates generated mappers and parsers for a complete type-safe GraphQL requests, for developers that uses Apollo Android runtime.
Config API Reference
package
type: string
Customize the Java package name for the generated operations. The default package name will be generated according to the output file path.
Usage Examples
generates:
./app/src/main/java/:
preset: java-apollo-android
config:
package: 'com.my.package.generated.graphql'
plugins:
- java-apollo-androidtypePackage
type: string
Customize the Java package name for the types generated based on input types.
Usage Examples
generates:
./app/src/main/java/:
preset: java-apollo-android
config:
typePackage: 'com.my.package.generated.graphql'
plugins:
- java-apollo-androidfragmentPackage
type: string
Customize the Java package name for the fragments generated classes.
Usage Examples
generates:
./app/src/main/java/:
preset: java-apollo-android
config:
fragmentPackage: 'com.my.package.generated.graphql'
plugins:
- java-apollo-androidfileType
type: FileType
Prepare your env
To get started with these plugins and preset, make sure you have the following installed:
- Node.js (10 or later)
- NPM or Yarn
Run the following in your Android project:
npm init --yes
npm install graphql
npm install -D @graphql-codegen/cli @graphql-codegen/java-apollo-androidThen, create codegen.yml with the following configuration:
schema: POINT_TO_YOUR_SCHEMA
documents: POINT_TO_YOUR_GRAPHQL_OPERATIONS
generates:
./app/src/main/java/:
preset: java-apollo-android
config:
package: 'com.my.app.generated.graphql'
fragmentPackage: 'com.my.app.generated.graphql'
typePackage: 'type'
plugins:
- java-apollo-androidnode_modules to your .gitignore file.To integrate with your Gradle build, you can add the following to your app Gradle file:
preBuild.doFirst {
def proc = "yarn graphql-codegen".execute()
proc.waitForProcessOutput(System.out, System.err)
}
build.dependsOn preBuildThis will make sure to run and generate output before each time you build your project.
Usage
You can find a repository with a working example using AppSync.