createAllAndroidVariantServices

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

registers multiple services for an android project

Android projects have variants for buildType/flavor combinations as well as test. Using this method will create a service for each application/library variant and add the generated sources to the variant. A variant typically contains several source sets as described in https://developer.android.com/studio/build/build-variants?authuser=2#sourceset-build. This means you can put graphql files in several folders:

  • src/main/graphql/$sourceFolder/MainQuery.graphql will be added to all variants

  • src/debug/graphql/$sourceFolder/DebugQuery.graphql will be added to all debug variants

  • src/demoDebug/graphql/$sourceFolder/DemoDebugQuery.graphql will be added to the demoDebug variant

There is no concept of "priority". It is not possible to "override" queries in narrower source sets. You can use the same file names in the different source sets but the operations should be disjoint between different variants. If the same operation is added multiple times, an error will be thrown like for Java/Kotlin classes.

Parameters

sourceFolder

: where to look for "*.graphql" files, relative to "src/$sourceSetName/graphql". You can pass "." to look into "src/$sourceSetName/graphql"

nameSuffix

: the suffix to use to name the services. A service will be created per Android variant named "$variant${nameSuffix.capitalize()}". For an example, if nameSuffix = starwars, the below services will be created:

  • debugStarwars

  • releaseStarwars

  • debugAndroidTestStarwars

  • releaseAndroidTestStarwars

  • debugUnitTestStarwars

  • releaseUnitTestStarwars If your project has multiple flavours or build types, services will be created for those as well

nameSuffix name must be unique

action

: an action to configure the packageName and other parameters on each service. Will be called once for each variant