apollo-kotlin: Apollo doesn't take into account Android build type graphQL overrides
Summary Overriding graphQL files using the AGPs build type aware source directory approach isn’t taken into account by the apollo Gradle plugin.
Version 2.2.3
Description We are aiming at overriding certain graphQL queries for our release build type. The Android approach would usually look like this:
- Define the a default (in our case used for stage and debug builds) query in the main source directory, e.g. app/src/main/graphql/your/app/buildid/datasource/cms/Articles.graphql
- Override the default query in the release source directory, in this case app/src/release/graphql/your/app/buildid/datasource/cms/Articles.graphql
- This should normally result in the app/src/release/…/Articles.graphql being used for release builds, but that doesn’t seem to be the case - instead the app/src/main/…/Articles.graphql is used.
Here is my apollo Gradle plugin configuration - not sure it is relevant to solving this issue:
apollo {
generateKotlinModels.set(true)
schemaFile = file("src/main/graphql/schema.json")
customTypeMapping = [
"Date" : "java.util.Date"
]
}
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 23 (16 by maintainers)
Hi @m-abyzov !
The new way to take Android buildTypes / variants into accounts is with
createAllAndroidVariantServices
.For example:
The documentation is here.
Let us know if that works for you!
Hello @m-abyzov and @timkabot, just a follow-up to say that we’ve added a section on the documentation about
createAllAndroidVariantServices
here, and also made a change so thattestDebug
no longer triggers the code generation for all the variants (will be in the next release and can be tried now with the snapshots).Please don’t hesitate to tell us if you need any other clarification or help related to this.
@m-abyzov You could get the list of variants from the
android
extension, and configure a service for each, something like this:This is essentially a simplified version of what
createAllAndroidVariantServices
does.Removing the schema file declaration from the Apollo Gradle plugin configuration did the trick! 🤗 Everything now works as it should. Many thanks for the great support @martinbonnin! ❤️