Jan Skrasek
08/03/2022, 8:18 AMIf two sibling modules use the same schema type and this schema type wasn't generated upstream, each module will generate its own version of the schema type, which could clash. To prevent this, Apollo Kotlin registers a global "check${service}ApolloDuplicates" task that will fail if there are duplicates.Hello. I do not much understand this. • Could clash means exactly what? Our two modules has different package names, so I guess they cannot clash, can they? • Is the check "preemptive" in a way it fails even they do not clash (because of those package names)? Thank you 🙂
mbonnin
08/03/2022, 8:19 AMOur two modules has different package names, so I guess they cannot clash, can theyThat's the catch. Because there's only one schema, all the "schema" types will use the same package name
:schema
- schema.graphqls
- query1 that uses input type Input1
:feature
- query1 that uses input type Input2
Then Input2
is going to be generated in the "feature" module
But if you move that query to the "schema" module (or just add a new one there), it's going to be moved to the "schema" module.
Because we don't want that move to break things, we use the same package name for all "schema" typesalwaysGenerateTypesMatching.set(listOf(".*"))
in your schema module but this might generate a bit more code (or sometimes a lot depending your schema)Jan Skrasek
08/03/2022, 8:29 AMWhich is the package name of the "schema" moduleSo ours feature module setup will not work?
val packagePath = "xxx." + path.replace(":", ".") + ".network"
packageName.set(packagePath)
mbonnin
08/03/2022, 8:29 AMpackageName
option in the Gradle setup for historical reasons but in multi-modules setup, there are in reality 2 packageName
sJan Skrasek
08/03/2022, 8:34 AMmbonnin
08/03/2022, 8:37 AMJan Skrasek
08/03/2022, 8:41 AMmbonnin
08/03/2022, 8:46 AMJan Skrasek
08/03/2022, 8:46 AMmbonnin
08/03/2022, 8:47 AMalwaysGenerateTypeMatching
logic that needs to be donealwaysGenerateTypeMatching
for different nodes in your module graph automaticallyJan Skrasek
08/03/2022, 8:49 AMmbonnin
08/03/2022, 8:51 AMBecause the current check doesn't tell us that, right?The current check will tell you something like:
type 'SomeInputType' is used in sibling modules :feature1 :feature2, use alwaysGenerateTypesMatching in a parent module
4039 is about getting the alwaysGenerateTypesMatching
values from a file that can be computed automatically by some task that scans the whole module graphJan Skrasek
08/03/2022, 8:53 AMmbonnin
08/03/2022, 8:53 AMWe wouldn't mind having some types duplicated in feature modulesFeel free to open an issue about this and we can experiment
Jan Skrasek
08/03/2022, 8:58 AMmbonnin
08/03/2022, 9:00 AM