DefaultService

abstract class DefaultService @Inject constructor(val project: Project, val name: String) : Service

Constructors

Link copied to clipboard
@Inject
constructor(project: Project, name: String)

Properties

Link copied to clipboard
abstract 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
abstract val addTypename: Property<String>

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

Link copied to clipboard
abstract 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
abstract val classesForEnumsMatching: ListProperty<String>

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

Link copied to clipboard
abstract val codegenModels: Property<String>

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

Link copied to clipboard
abstract val debugDir: DirectoryProperty

A debug directory where the compiler will output intermediary results

Link copied to clipboard
abstract val decapitalizeFields: Property<Boolean>

Whether to decapitalize fields (for instance FooBar ->fooBar). This is useful if your schema has fields starting with an uppercase as it may create name clashes with models that use PascalCase

Link copied to clipboard
abstract val excludes: ListProperty<String>

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

Link copied to clipboard
abstract 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
abstract val fieldsOnDisjointTypesMustMerge: Property<Boolean>

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

Link copied to clipboard
abstract 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
abstract val generateApolloMetadata: Property<Boolean>

Whether to generate Apollo metadata. Apollo metadata is used for multimodule 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
abstract val generateAsInternal: Property<Boolean>

Whether to generate Kotlin models with internal visibility modifier.

Link copied to clipboard

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
abstract val generatedSchemaName: Property<String>

Class name to use when generating the Schema class.

Link copied to clipboard

Whether to generate the com.apollographql.apollo.api.Fragment as well as response and variables adapters.

Link copied to clipboard

Whether to generate builders in addition to constructors for operations and input types. Constructors are more concise but require passing an instance of Optional always, making them more verbose for the cases where there are a lot of optional input parameters.

Link copied to clipboard
abstract val generateKotlinModels: Property<Boolean>

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

Link copied to clipboard
abstract val generateMethods: ListProperty<String>

Specifies which methods will be auto generated on operations, models, fragments and input objects.

Link copied to clipboard

Whether to generate builders for java models

Link copied to clipboard

Whether to generate the operationOutput.json

Link copied to clipboard

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

Link copied to clipboard
abstract 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
abstract val generateQueryDocument: Property<Boolean>

Whether to embed the query document in the com.apollographql.apollo.api.Operations. By default, this is true as it is needed to send the operations to the server. If performance/binary size is critical, and you are using persisted queries or a similar mechanism, disable this.

Link copied to clipboard
abstract val generateSchema: Property<Boolean>

Whether to generate the Schema class.

Link copied to clipboard
val graphqlSourceDirectorySet: SourceDirectorySet
Link copied to clipboard
abstract val includes: ListProperty<String>

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

Link copied to clipboard
Link copied to clipboard
abstract val jsExport: Property<Boolean>

Whether to add the JsExport annotation to generated models. This is useful to be able to cast JSON parsed responses into Kotlin classes using unsafeCast.

Link copied to clipboard
abstract val languageVersion: Property<String>

Target language version for the generated code.

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

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

Link copied to clipboard

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
abstract 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
abstract val operationManifestFormat: Property<String>

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

Link copied to clipboard

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

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
abstract 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
Link copied to clipboard
abstract val packageName: Property<String>

The package name for generated classes. Operations use the package name directly. Other classes like fragments and schema types use sub-packages to avoid name clashes:

Link copied to clipboard

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

Link copied to clipboard
val project: Project
Link copied to clipboard
Link copied to clipboard

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

Link copied to clipboard
Link copied to clipboard
abstract val schemaFile: RegularFileProperty

The location of the main schema file.

Link copied to clipboard
abstract val schemaFiles: ConfigurableFileCollection

The schema files in either ".json" introspection schemas or ".sdl|.graphqls" SDL schemas.

Link copied to clipboard
abstract 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

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

Link copied to clipboard
abstract val useSemanticNaming: Property<Boolean>

When true, the operation class names are suffixed with their operation type like ('Query', 'Mutation' ot 'Subscription'). For an example, query getDroid { ... } GraphQL query generates the 'GetDroidQuery' class.

Link copied to clipboard
abstract val warnOnDeprecatedUsages: Property<Boolean>

Warn if using a deprecated field

Functions

Link copied to clipboard
open override fun dependsOn(dependencyNotation: Any)

Adds a dependency for the codegen. Use this when some types/fragments are generated in upstream modules.

open override fun dependsOn(dependencyNotation: Any, bidirectional: Boolean)

Same as dependsOn but allows for automatic detection of used types. This works by adding the current project to the upstream project dependencies using cross-project configuration.

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 isADependencyOf(dependencyNotation: Any)

Counterpoint of dependsOn. isADependencyOf allows a schema module to discover used types in downstream modules automatically without having to specify alwaysGenerateTypesMatching.

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.apollo.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.apollo.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.apollo.api.Upload and use the builtin adapter

Link copied to clipboard

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

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 plugin(dependencyNotation: Any)
open override fun plugin(dependencyNotation: Any, block: Action<CompilerPlugin>)
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 srcDir(directory: Any)

Adds the given directory as a GraphQL source root