DefaultApolloExtension

abstract class DefaultApolloExtension(project: Project, defaultService: DefaultService) : ApolloExtension, Service

Constructors

Link copied to clipboard
fun DefaultApolloExtension(project: Project, defaultService: DefaultService)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open override fun createAllAndroidVariantServices(    sourceFolder: String,     nameSuffix: String,     action: Action<Service>)

registers multiple services for an android project

Link copied to clipboard
open override fun createAllKotlinSourceSetServices(    sourceFolder: String,     nameSuffix: String,     action: Action<Service>)

registers multiple services for a Kotlin project

Link copied to clipboard
open override fun introspection(configure: Action<in Introspection>)

Configures Introspection to download an introspection Json schema

Link copied to clipboard
open override fun mapScalar(graphQLName: String, targetName: String)

Map a GraphQL scalar type to the Java/Kotlin type. The adapter must be configured at runtime via com.apollographql.apollo3.ApolloClient.Builder.addCustomScalarAdapter.

open override fun mapScalar(    graphQLName: String,     targetName: String,     expression: String)

Map a GraphQL scalar type to the Java/Kotlin type and provided adapter expression. The adapter will be configured at compile time and you must not call com.apollographql.apollo3.ApolloClient.Builder.addCustomScalarAdapter.

Link copied to clipboard
open override fun mapScalarToJavaBoolean(graphQLName: String)

Map the given GraphQL scalar to java.lang.Boolean and use the builtin adapter

Link copied to clipboard
open override fun mapScalarToJavaDouble(graphQLName: String)

Map the given GraphQL scalar to java.lang.Double and use the builtin adapter

Link copied to clipboard
open override fun mapScalarToJavaFloat(graphQLName: String)

Map the given GraphQL scalar to java.lang.Float and use the builtin adapter

Link copied to clipboard
open override fun mapScalarToJavaInteger(graphQLName: String)

Map the given GraphQL scalar to java.lang.Integer and use the builtin adapter

Link copied to clipboard
open override fun mapScalarToJavaLong(graphQLName: String)

Map the given GraphQL scalar to java.lang.Long and use the builtin adapter

Link copied to clipboard
open override fun mapScalarToJavaObject(graphQLName: String)

Map the given GraphQL scalar to java.lang.Object and use the builtin adapter

Link copied to clipboard
open override fun mapScalarToJavaString(graphQLName: String)

Map the given GraphQL scalar to java.lang.String and use the builtin adapter

Link copied to clipboard
open override fun mapScalarToKotlinAny(graphQLName: String)

Map the given GraphQL scalar to kotlin.Any and use the builtin adapter

Link copied to clipboard
open override fun mapScalarToKotlinBoolean(graphQLName: String)

Map the given GraphQL scalar to kotlin.Boolean and use the builtin adapter

Link copied to clipboard
open override fun mapScalarToKotlinDouble(graphQLName: String)

Map the given GraphQL scalar to kotlin.Double and use the builtin adapter

Link copied to clipboard
open override fun mapScalarToKotlinFloat(graphQLName: String)

Map the given GraphQL scalar to kotlin.Float and use the builtin adapter

Link copied to clipboard
open override fun mapScalarToKotlinInt(graphQLName: String)

Map the given GraphQL scalar to kotlin.Int and use the builtin adapter

Link copied to clipboard
open override fun mapScalarToKotlinLong(graphQLName: String)

Map the given GraphQL scalar to kotlin.Long and use the builtin adapter

Link copied to clipboard
open override fun mapScalarToKotlinString(graphQLName: String)

Map the given GraphQL scalar to kotlin.String and use the builtin adapter

Link copied to clipboard
open override fun mapScalarToUpload(graphQLName: String)

Map the given GraphQL scalar to com.apollographql.apollo3.api.Upload and use the builtin adapter

Link copied to clipboard
open override fun operationManifestConnection(action: Action<in Service.OperationManifestConnection>)

overrides the way the operation manifest is connected. Use this if you want to connect the generated operation manifest. For an example you can use this to send the modified queries to your backend for whitelisting

Link copied to clipboard
open override fun operationOutputConnection(action: Action<in Service.OperationOutputConnection>)

overrides the way operationOutput is connected. Use this if you want to connect the generated operationOutput. For an example you can use this to send the modified queries to your backend for whitelisting

Link copied to clipboard
open override fun outputDirConnection(action: Action<in Service.DirectoryConnection>)

Overrides the way the generated models are connected. Use this if you want to connect the generated models to another task than the default destination.

Link copied to clipboard
open override fun packageNamesFromFilePaths(rootPackageName: String?)

A helper method to configure a PackageNameGenerator that will use the file path relative to the source roots to generate the packageNames

Link copied to clipboard
open override fun registerOperations(configure: Action<in RegisterOperationsConfig>)

Configures operation safelisting (requires an Apollo Studio account)

Link copied to clipboard
open override fun registry(configure: Action<in Registry>)

Configures Registry to download a SDL schema from a studio registry

Link copied to clipboard
open override fun service(name: String, action: Action<Service>)

Call from users to explicitly register a service or by the plugin to register the implicit service

Link copied to clipboard
open override fun srcDir(directory: Any)

Adds the given directory as a GraphQL source root

Link copied to clipboard
open override fun testDirConnection(action: Action<in Service.DirectoryConnection>)

Overrides the way the generated test builders are connected. Use this if you want to connect the generated test builders to another task than the default destination.

Link copied to clipboard
open override fun usedCoordinates(file: File)

By default, the used coordinates are computed automatically from all modules sharing a schema. This means that changing a query in a module might trigger task execution in a completely different module. If your used coordinates do not change too often, you can opt-in to save them in a file that is read instead of checking all modules.

open override fun usedCoordinates(file: String)
Link copied to clipboard
open override fun useVersion2Compat(rootPackageName: String?)

A shorthand method that configures defaults that match Apollo Android 2.x codegen

Properties

Link copied to clipboard
open override val addJvmOverloads: Property<Boolean>

Whether to generate kotlin constructors with @JvmOverloads for more graceful Java interop experience when default values are present. Note: when enabled in a multi-platform setup, the generated code can only be used in the common or JVM sourcesets.

Link copied to clipboard
open override val addTypename: Property<String>

When to add __typename. One of "always", "ifFragments", "ifAbstract" or "ifPolymorphic"

Link copied to clipboard
open override val alwaysGenerateTypesMatching: SetProperty<String>

A list of Regex patterns matching schema coordinates for types and fields that should be generated whether they are used by queries/fragments in this module or not.

Link copied to clipboard
open override val classesForEnumsMatching: ListProperty<String>

A list of Regex patterns for GraphQL enums that should be generated as Java classes.

Link copied to clipboard
open override val codegenModels: Property<String>

What codegen to use. One of "operationBased", "responseBased", "compat" or "experimental_operationBasedWithInterfaces"

Link copied to clipboard
open override val compilerJavaHooks: ListProperty<ApolloCompilerJavaHooks>

Hooks to customize the generated Java code.

Link copied to clipboard
open override val compilerKotlinHooks: ListProperty<ApolloCompilerKotlinHooks>

Hooks to customize the generated Kotlin code.

Link copied to clipboard
open override val customScalarsMapping: MapProperty<String, String>

For custom scalar types like Date, map from the GraphQL type to the Java/Kotlin type.

Link copied to clipboard
open override val customTypeMapping: MapProperty<String, String>
Link copied to clipboard
open override val debugDir: DirectoryProperty

A debug directory where the compiler will output intermediary results

Link copied to clipboard
open override val decapitalizeFields: Property<Boolean>

Whether to decapitalize field names in the generated models (for instance FooBar ->fooBar).

Link copied to clipboard
open override val excludes: ListProperty<String>

Operation files to exclude. The values are interpreted as in org.gradle.api.tasks.util.PatternFilterable

Link copied to clipboard
open override val failOnWarnings: Property<Boolean>

Fail the build if there are warnings. This is not named allWarningAsErrors to avoid nameclashes with the Kotlin options

Link copied to clipboard
open override val fieldsOnDisjointTypesMustMerge: Property<Boolean>

Whether fields with different shape are disallowed to be merged in disjoint types.

Link copied to clipboard
open override val flattenModels: Property<Boolean>

Whether to flatten the models. File paths are limited on MacOSX to 256 chars and flattening can help keeping the path length manageable The drawback is that some classes may nameclash in which case they will be suffixed with a number

Link copied to clipboard
open override val generateApolloMetadata: Property<Boolean>

Whether to generate Apollo metadata. Apollo metadata is used for multi-module support. Set this to true if you want other modules to be able to re-use fragments and types from this module.

Link copied to clipboard
open override val generateAsInternal: Property<Boolean>

Whether to generate Kotlin models with internal visibility modifier.

Link copied to clipboard
open override val generateDataBuilders: Property<Boolean>

Whether to generate the type safe Data builders. These are mainly used for tests but can also be used for other use cases too.

Link copied to clipboard
open override val generatedSchemaName: Property<String>

Class name to use when generating the Schema class.

Link copied to clipboard
open override val generateFragmentImplementations: Property<Boolean>

Whether to generate default implementation classes for GraphQL fragments. Default value is false, means only interfaces are generated.

Link copied to clipboard
open override val generateKotlinModels: Property<Boolean>

Whether to generate Kotlin or Java models Default to true if the Kotlin plugin is found

Link copied to clipboard
open override val generateModelBuilder: Property<Boolean>

Whether to generate response model builders for Java.

Link copied to clipboard
open override val generateModelBuilders: Property<Boolean>

Whether to generate response model builders for Java.

Link copied to clipboard
open override val generateOperationOutput: Property<Boolean>

Whether to generate the operationOutput.json

Link copied to clipboard
open override val generateOptionalOperationVariables: Property<Boolean>

Whether to generate operation variables as com.apollographql.apollo3.api.Optional

Link copied to clipboard
open override val generatePrimitiveTypes: Property<Boolean>

Whether to generate fields as primitive types (int, double, boolean) instead of their boxed types (Integer, Double, Boolean) when possible.

Link copied to clipboard
open override val generateQueryDocument: Property<Boolean>

Whether to write the query document in models

Link copied to clipboard
open override val generateSchema: Property<Boolean>

Whether to generate the Schema class. The Schema class lists all composite types in order to access __typename and/or possibleTypes.

Link copied to clipboard
abstract override val generateSourcesDuringGradleSync: Property<Boolean>

Adds "generateApolloSources" as a dependency of "prepareKotlinIdeaImport" This makes IDEA aware of codegen and will run it during your Gradle Sync

Link copied to clipboard
open override val generateTestBuilders: Property<Boolean>

Whether to generate the type safe Data builders. These are mainly used for tests but can also be used for other use cases too.

Link copied to clipboard
open override val includes: ListProperty<String>

Operation files to include. The values are interpreted as in org.gradle.api.tasks.util.PatternFilterable

Link copied to clipboard
open override val languageVersion: Property<String>

Target language version for the generated code.

Link copied to clipboard
abstract override val linkSqlite: Property<Boolean>

For Kotlin native projects, whether to link Sqlite (-lsqlite3). This is required by apollo-normalized-cache-sqlite but some projects might want to customize linker options

Link copied to clipboard
open override val name: String
Link copied to clipboard
open override val nullableFieldStyle: Property<String>

The style to use for fields that are nullable in the Java generated code.

Link copied to clipboard
open override val operationIdGenerator: Property<OperationIdGenerator>

By default, Apollo uses Sha256 hashing algorithm to generate an ID for the query. To provide a custom ID generation logic, pass an instance that implements the OperationIdGenerator. How the ID is generated is indifferent to the compiler. It can be a hashing algorithm or generated by a backend.

Link copied to clipboard
open override val operationManifest: RegularFileProperty

The file where to write the operation manifest. If you want a RegularFileProperty that carries the task dependency, use operationManifestConnection.

Link copied to clipboard
open override val operationManifestFormat: Property<String>

The format to output for the operation manifest. Valid values are:

Link copied to clipboard
open override val operationOutputFile: RegularFileProperty

The file where the operation output will be written. It's called operationOutputFile but this an "input" parameter for the compiler If you want a RegularFileProperty that carries the task dependency, use operationManifestConnection

Link copied to clipboard
open override val operationOutputGenerator: Property<OperationOutputGenerator>

A generator to generate the operation output from a list of operations. OperationOutputGenerator is similar to OperationIdGenerator but can work on lists. This is useful if you need to register/whitelist your operations on your server all at once.

Link copied to clipboard
open override val outputDir: DirectoryProperty

The directory where the generated models will be written. It's called outputDir but this an "input" parameter for the compiler If you want a DirectoryProperty that carries the task dependency, use outputDirConnection

Link copied to clipboard
open override val packageName: Property<String>

The package name of the models. The compiler will generate classes in

Link copied to clipboard
open override val packageNameGenerator: Property<PackageNameGenerator>

Use packageNameGenerator to customize how to generate package names from file paths.

Link copied to clipboard
open override val requiresOptInAnnotation: Property<String>

The annotation to use for @requiresOptIn fields/inputFields/enumValues

Link copied to clipboard
open override val schemaFile: RegularFileProperty

A shorthand property that will be used if schemaFiles is empty

Link copied to clipboard
open override val schemaFiles: ConfigurableFileCollection

The schema files as either a ".json" introspection schema or a ".sdl|.graphqls" SDL schema. You might come across schemas named "schema.graphql", these are SDL schemas most of the time that need to be renamed to "schema.graphqls" to be recognized properly.

Link copied to clipboard
open override val sealedClassesForEnumsMatching: ListProperty<String>

A list of Regex patterns for GraphQL enums that should be generated as Kotlin sealed classes instead of the default Kotlin enums.

Link copied to clipboard
open override val sourceFolder: Property<String>

Where to look for GraphQL sources. The plugin will look in "src/main/graphql/$sourceFolder" for Android/JVM projects and "src/commonMain/graphql/$sourceFolder" for multiplatform projects.

Link copied to clipboard
open override val testDir: DirectoryProperty

The directory where the test builders will be written. If you want a DirectoryProperty that carries the task dependency, use outputDirConnection

Link copied to clipboard
open override val useSchemaPackageNameForFragments: Property<Boolean>

Whether to use the schema package name for fragments. This is used for backward compat with 2.x

Link copied to clipboard
open override val useSemanticNaming: Property<Boolean>

When true, the generated classes names will end with 'Query' or 'Mutation'. If you write query droid { ... }, the generated class will be named 'DroidQuery'.

Link copied to clipboard
open override val warnOnDeprecatedUsages: Property<Boolean>

Warn if using a deprecated field