:wave: Sorry this might be a silly one, but Im tr...
# apollo-kotlin
m
👋 Sorry this might be a silly one, but Im trying to move to variant services for apollo kotlin. Im following the doc But Im getting a
Could not set unknown property 'nameSuffix' for extension 'apollo'
🤔
Copy code
createAllAndroidVariantServices(sourceFolder = ".", nameSuffix = "") {
        
        packageName.set("package-here")
        schemaFile.set(file("src/main/graphql/core/schema.json"))
        mapScalar("DateTime", "org.threeten.bp.ZonedDateTime")
        mapScalar("Date", "org.threeten.bp.LocalDate")
        mapScalar("UUID", "kotlin.String")
        generateAsInternal.set(true)
Copy code
}
m
Interesting. Are you using Groovy build scripts by any chance? The syntax for passing named parameters might be different
More generally, may I ask if you really need one codegen per variant? I'm thinking of deprecating the
createAllAndroidVariantServices
function. It was put there for compat with 2.x mainly but it creates a lot of tasks while most of the times, you usually want debug vs release or so
(Even that could be argued actually, these days I'd rather use branches to test agains pre-preod endpoints)
m
Yeah its a groovy build.gradle file. But the same syntax works with my previous implementation
Copy code
apollo {
    
    packageName.set("energy.octopus.fieldservices.library.network.datasource.graphql")
    mapScalar("DateTime", "org.threeten.bp.ZonedDateTime")
    mapScalar("Date", "org.threeten.bp.LocalDate")
    mapScalar("UUID", "kotlin.String")
    generateAsInternal.set(true)

    schemaFile.set(file("src/main/graphql/core/schema.json"))
    srcDir(file("src/main/graphql"))

}
as per the variants configuraiton we are going to be releasing different country/variants apps and that seemed liek the way to go
( yes different countries will have different schemas)
m
Copy code
createAllAndroidVariantServices(sourceFolder = ".", nameSuffix = "")
I'd say (but not 100% sure) this doesn't work in Groovy
different countries will have different schemas
Does that mean they have different queries too ? 👀
m
most likely yeah 😬
m
Gotcha 👍
FWIW, variants is more than countries: • ukDebug • ukRelease • usDebug • usRelease • frDebug • frRelease • and then all the test variants...
So this means you're running a different codegen for each variant even if some of them might have the same GraphQL files (ukDebug and ukRelease for an example)
m
yeah you are right on that one
If you have many variants and don't need to configure an Apollo Service for each one of them, it may be simpler to declare the Services manually, for instance:
Might as well try this
And have per country services
m
It's 'cleaner'
m
Gotcha, appreciated !
m
And might save you a bit of build time esp in CI where you build several variants