Stylianos Gakis
11/06/2023, 4:02 PM3.8.2
I got a root apollo module with
...
packageName.set("octopus")
generateApolloMetadata.set(true)
generateDataBuilders.set(true)
Then in a feature module, I got
apollo {
service("octopus") {
packageName.set("octopus") // Tried with "octopus.home" too, to have them be different
generateDataBuilders.set(true)
}
}
.
In my feature module then in a test, I was trying to create an instance of a response, and it seems like it’s not generating the right thing which comes from my feature module.
So in my root apollo module, I got a query which asks for a type, but only asks for a subset of the fields in there.
The feature module asks for a unique field which wasn’t asked before, and the data builder does not generate the right builder. Basically in one place, for the public fun BuilderScope.buildProductVariant(block: ProductVariantBuilder.() -> Unit)
function, the ProductVariantBuilder
only contains the fields that are present in the home module queries.
I have confirmed now that adding the field in the root module (despite not needing it there), generates the right data builder, and only the fields that I have there, not the ones that are in the feature module.
Does this sound like something that I am doing wrong, or something that may be wrong with data builders in 3.x? I didn’t check with 4.x atm, but if you know for example that this is solved there then just let me know and I’ll work around it for now until I can go to 4.x.mbonnin
11/06/2023, 4:06 PMalwaysGenerateTypesMatching.set(listOf("*"))
)
2. or configure the "back links" so that the root module gets the used coordinates from the feature modulembonnin
11/06/2023, 4:07 PMStylianos Gakis
11/06/2023, 4:08 PMconfiguring back links
look like? I don’t think I’ve read the docs around that yet 👀mbonnin
11/06/2023, 4:08 PMalwaysGenerateTypesMatching.set(listOf("Type.yourField"))
(I think this works in V3 but wouldn't put my hand on it)mbonnin
11/06/2023, 4:09 PMStylianos Gakis
11/06/2023, 4:09 PMmbonnin
11/06/2023, 4:09 PMStylianos Gakis
11/06/2023, 4:10 PMmbonnin
11/06/2023, 4:10 PMmbonnin
11/06/2023, 4:11 PMmbonnin
11/06/2023, 4:12 PMapolloUsedCoordinates
configurations or so but it's not documented and had a bunch of issues so better wait until v4Stylianos Gakis
11/06/2023, 4:13 PMisADependencyOf
for X feature modules you got with this configuration + 1 dependsOn
per feature module with gql files, and it should then all work well togethermbonnin
11/06/2023, 4:13 PMmbonnin
11/06/2023, 4:14 PMStylianos Gakis
11/06/2023, 4:14 PMStylianos Gakis
11/06/2023, 4:15 PMmbonnin
11/06/2023, 4:16 PMStylianos Gakis
11/06/2023, 4:16 PMfeatures {
anvil()
blahblah()
}
And have that maybe somehow hook everything together. But this is definitely a stretch, I am only imagining here, I do not have anything concrete on my mind.
Seen something like this mentioned here https://androidstudygroup.slack.com/archives/C0SFT151T/p1674252933934949Stylianos Gakis
11/06/2023, 4:17 PMmbonnin
11/06/2023, 4:18 PMmbonnin
11/06/2023, 4:21 PMproject(":schema").dependencies {
add("apolloUsedCoordinates", project)
}
in a way that doesn't break all the Gradle logicmbonnin
11/06/2023, 4:22 PMblock: Action<T>
parameters. Gradle will generate magic bytecode to have your function accept both a Kotlin function type (works out of the box with SAM conversion) and a Groovy closure (requires magic bytecode)Stylianos Gakis
11/06/2023, 4:29 PMhedvig {
apollo()
}
Which would setup the dependencies + setup dependsOn(project(":schema"))
Now at that point I don’t know if that convention plugin can also check all those callers who call apollo()
and then also setup isADependencyOf
accordingly.
A question, if the root module does isADependencyOf
for all modules? So that you can just add that and only need to care for the child modules after that? Or does that fail during compilation?mbonnin
11/06/2023, 4:32 PMI don’t know if that convention plugin can also check all those callers who callYea, that's the issue sad panda . I don't think it's safe to iterate the projects from a convention pluginand then also setupapollo()
accordingly.isADependencyOf
root moduleI try to refer it as the "schema module". It doesn't have to be your root project in the Gradle acceptation of the term
you can just add that and only need to care for the child modules after thatIf you can iterate all projects, then it might work but I'm not sure how "project isolation-compatible" this is.
mbonnin
11/06/2023, 4:32 PMStylianos Gakis
11/06/2023, 4:33 PMroot module
I did in fact mean the root apollo module
not the actual root module. That’s what we do too.mbonnin
11/06/2023, 4:33 PMmbonnin
11/06/2023, 4:34 PMStylianos Gakis
11/06/2023, 4:57 PMYang
11/06/2023, 10:41 PMmbonnin
11/07/2023, 12:23 AMYang
11/07/2023, 1:02 AMYang
11/07/2023, 1:05 AMmbonnin
11/07/2023, 8:25 AMYang
07/31/2024, 11:16 AMmbonnin
07/31/2024, 11:24 AMisADependencyOf()
should do it!mbonnin
07/31/2024, 11:25 AMmbonnin
07/31/2024, 11:25 AMmbonnin
07/31/2024, 11:26 AMdependsOn(dependencyNotation = project(":schema"), bidirectional = true)
mbonnin
07/31/2024, 11:26 AMmbonnin
07/31/2024, 11:27 AMYang
07/31/2024, 11:42 AMYang
07/31/2024, 11:43 AMmbonnin
07/31/2024, 11:44 AMYang
07/31/2024, 11:47 AMdependsOn
also break project isolation?mbonnin
07/31/2024, 11:49 AMmbonnin
07/31/2024, 11:49 AMdependencies {
implementation(project(":schema"))
}
would be compatiblembonnin
07/31/2024, 11:50 AMYang
07/31/2024, 11:52 AMbidirectional
needs to resolve more things from schema
when configuring the project?mbonnin
07/31/2024, 11:52 AMmbonnin
07/31/2024, 11:53 AMmbonnin
07/31/2024, 11:53 AMmbonnin
07/31/2024, 11:54 AMdependencies.project(":schema")
doesn’t return a Project
instance, Project.project(":schema")
does)Yang
08/08/2024, 7:36 AMbidirectional
, is it only meant for the modules that has a schema, or does it also work on the other modules that produces metadata e.g. for sharing fragment?mbonnin
08/08/2024, 7:37 AMYang
08/08/2024, 7:38 AMYang
08/08/2024, 7:39 AM:feature
module that has dependsOn
on :schema
, but also another dependsOn
on a :sdui
module with GraphQL fragmentYang
08/08/2024, 7:41 AMdependsOn(project(":schema"), bidirectional = true)
and dependsOn(project(":sdui"), bidirectional = true)
?mbonnin
08/08/2024, 7:44 AMmbonnin
08/08/2024, 7:44 AMsdui
modulembonnin
08/08/2024, 7:45 AMYang
08/08/2024, 7:46 AMYang
08/08/2024, 7:48 AMmbonnin
08/08/2024, 7:54 AMmbonnin
08/08/2024, 7:54 AMYang
08/08/2024, 7:55 AMmbonnin
08/08/2024, 7:55 AMmbonnin
08/08/2024, 7:55 AMYang
08/08/2024, 7:56 AMmbonnin
08/08/2024, 7:57 AMmbonnin
08/08/2024, 7:58 AMYang
08/08/2024, 8:05 AMYang
08/08/2024, 8:05 AMbuild
folder is identicalmbonnin
08/08/2024, 8:07 AMalwaysGenerateTypesMatching
?Yang
08/08/2024, 8:09 AMalwaysGenerateTypesMatching.set(listOf(".*"))
and I removed it immediatelyYang
08/08/2024, 8:12 AM