Kotlin
| Package name | Weekly Downloads | Version | License | Updated |
|---|---|---|---|---|
@graphql-codegen/kotlin | Apr 19th, 2026 |
Installation
npm i -D @graphql-codegen/kotlinConfig API Reference
package
type: string
Customize the Java package name. The default package name will be generated according to the output file path.
Usage Examples
generates:
src/main/kotlin/my-org/my-app/Resolvers.kt:
plugins:
- kotlin
config:
package: custom.package.nameenumValues
type: unknown_1
Overrides the default value of enum values declared in your GraphQL schema.
listType
type: string
default: Iterable
Allow you to customize the list type
Usage Examples
generates:
src/main/kotlin/my-org/my-app/Types.kt:
plugins:
- kotlin
config:
listType: MapwithTypes
type: boolean
default: false
Allow you to enable generation for the types
Usage Examples
generates:
src/main/kotlin/my-org/my-app/Types.kt:
plugins:
- kotlin
config:
withTypes: trueomitJvmStatic
type: boolean
default: false
Allow you to omit JvmStatic annotation
The kotlin plugin generates Kotlin classes for Enums and Input types.
You can use this plugin to generate Java enums based on your GraphQL schema, and it also generates a
type-safe Kotlin transformer for GraphQL input types.
Prepare your environment
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/kotlinThen, create codegen.yml with the following configuration:
schema: POINT_TO_YOUR_SCHEMA
documents: POINT_TO_YOUR_GRAPHQL_OPERATIONS
generates:
./app/src/Types.kt:
plugins:
- kotlinnode_modules to your .gitignore file.