Hey, i’m trying to modularise the apollo queries w...
# apollo-kotlin
g
Hey, i’m trying to modularise the apollo queries within a mono-repo but getting duplicated class issue, currently this the structure i have:
Copy code
monorepo
  app-a module
    apollo-a module
  app-b module
    apollo-b module
Currently what i get is:
Cause: duplicate Type XXX generated in modules: apollo-b,apollo-a
What i have tried is this: within app-a:
Copy code
dependencies {
    implementation(project(":apollo-a"))
    apolloMetadata(project(":apollo-a"))
}
With apollo-a module:
Copy code
apollo {
    generateApolloMetadata.set(true)
    generateKotlinModels.set(true)
}
Any suggestions on this? Apollo version: 2.5.9
On top of this i also get this error:
Copy code
java.lang.IllegalStateException: Symbol for kotlin.collections/mutableMapOf|-4813910536206556932[0] is unbound
	at org.jetbrains.kotlin.ir.symbols.impl.IrBindablePublicSymbolBase.getOwner(IrPublicSymbolBase.kt:52)
	at org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionPublicSymbolImpl.getOwner(IrPublicSymbolBase.kt:74)
	at androidx.compose.compiler.plugins.kotlin.lower.LiveLiteralTransformer.visitCall(LiveLiteralTransformer.kt:663)
b
I’m not completely sure, but if you’re not trying to have a shared Apollo module between your 2 apps, would it make sense to generate the code in 2 separate packages (with
rootPackageName
) to avoid the clash?
this can be done in the root config of
apollo-a
and
apollo-b
g
Sorry, deleted my previous question but they are already generated as different packages, however apollo verification tasks fails.
b
oh 🤔
I’m guessing the issue is
apollo-a
and
apollo-b
are meant to be independent of each other in your case, but are not, and so the check kicks in.
they both define a schema, right?
g
yeah, they both have their own schema and one model an enum, is declared on both
each module is part of a different app, so they do not relate at all with each other and are in different packages
apollo’s check can’t differentiate from different dependency graphs, thus complains about duplication
b
I have the impression that this is not really supported (disclaimer: still a bit new to the project so may be wrong) 😅. But this sentence here: Multi-modules requires that one and only one module contains a schema.
g
i think my case is a different thing, i have it within a mono repo, so they are different projects and each has it’s own modules.
b
Would it be possible to have one common apollo module with 2 services (for each schema), and then
apollo-a
and
apollo-b
depending on it?
g
let me try if that can work
🤞 1
Do you know how the declarations would like look like from:
root level
gradle config and then from
apollo-a
and
apollo-b
modules?
i declared on the root level like:
Copy code
apollo {
    generateKotlinModels.set(true)
    generateApolloMetadata.set(true)

    service("service-a") {
        sourceFolder = "path"
        rootPackageName = "package"
    }

    service("service-b") {
        sourceFolder = "path"
        rootPackageName = "package"
    }
}
And then how would it look on the consumers?
b
I think assuming the module is named
root
, simply:
Copy code
apolloMetadata(project(":root"))
implementation(project(":root"))
wait do you mean the actual root project? Or did you create a specific module for this?
g
specific module, there’s not one “root”, as i mentioned before, it’s a mono-repo with several apps
👍 1