Skip to content
Latchkey

Apollo Federation composition error "INVALID_GRAPHQL" in CI

Federation composition merges subgraph schemas into one supergraph. When a subgraph defines something invalid or two subgraphs disagree, rover supergraph compose reports composition errors with codes like INVALID_GRAPHQL and exits non-zero.

What this error means

A rover supergraph compose step fails with "Encountered X build errors while trying to build a supergraph." and lines tagged [INVALID_GRAPHQL] naming the offending subgraph and type.

rover
Error: Encountered 1 build error while trying to build a supergraph.

Caused by:
    [INVALID_GRAPHQL] On subgraph "products": Unknown type "Money".

Common causes

A subgraph references an undefined type

A field uses a type the subgraph never defines or imports, so that subgraph schema is invalid and composition aborts.

Subgraphs disagree on a shared type or directive

Two subgraphs define the same type with incompatible shapes, or misuse a federation directive (@key, @external), producing a composition error.

How to fix it

Read the build error and fix the named subgraph

  1. Find the [INVALID_GRAPHQL] line and the subgraph it names.
  2. Define or import the missing type, or correct the federation directive.
  3. Re-run compose until it produces a supergraph cleanly.
Terminal
rover supergraph compose --config supergraph.yaml

Validate each subgraph before composing

Check subgraphs individually so an invalid one is caught before the compose step.

Terminal
rover subgraph check my-graph@current \
  --schema ./products.graphql --name products

How to prevent it

  • Compose the supergraph in CI on every subgraph change.
  • Keep shared types and federation directives consistent across subgraphs.
  • Validate each subgraph schema before composition.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →