We have a large multi-module Android project using Apollo Kotlin 5.0.1. To share
GraphQL fragments across features we put each shared fragment in its own Gradle
module and wire cross-module codegen with metadata:
apollo {
service("federation") {
packageName.set("...loyalty.offer")
dependsOn(projects.data.common.apollographql.federation.fragment.storedvalue, true)
}
}
A fragment is declared in module A and only referenced by operations/fragments in
module B (never by an operation inside module A itself). During codegen we get a
warning that the fragment is unused, e.g.:
w: .../FragmentResourceNotFoundError.graphql: (1, 1): Apollo: Fragment 'FragmentResourceNotFoundError' is not used
The fragment genuinely is used, just from a different module that depends on A
via dependsOn/generated metadata. We’d like to turn on warnings-as-errors for
the whole build, but these false-positive “unused fragment” warnings block that.
Questions:
- Is this a known limitation of the multi-module (metadata) codegen i.e. usage
isn’t propagated acrossdependsOnboundaries for the unused-fragment check? - Is there a supported way to suppress or downgrade only this warning (per
fragment, per service, or per module) without disabling other useful warnings? - Is co-locating fragments with a consumer, or adding a placeholder operation,
the intended workaround, or is there a first-class option we’re missing?