Multi-module codegen: "unused fragment" warnings for fragments used only in downstream modules

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:

  1. Is this a known limitation of the multi-module (metadata) codegen i.e. usage
    isn’t propagated across dependsOn boundaries for the unused-fragment check?
  2. Is there a supported way to suppress or downgrade only this warning (per
    fragment, per service, or per module) without disabling other useful warnings?
  3. 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?

Hi!

This is actually a known issue: False positive `fragment Foo is unused` in multi-module setup · Issue #6880 · apollographql/apollo-kotlin · GitHub

There is a workaround in the comments of that issue, to suppress the specific warning.

I recommend you add a :+1: reaction to that issue so we can prioritize it.

Let me know if you have any follow-up questions!