Expand description
Multi-subgraph federation composition validation and schema merging
This module implements comprehensive validation for composing multiple federated subgraphs into a single Apollo Federation supergraph. It validates:
- @key Consistency: All @extends types must use the same @key as the primary type
- @external Ownership: Each @external field must have exactly one owning subgraph
- @shareable Consistency: If a field is @shareable in one subgraph, it must be in all
- Type Merging: Proper composition of type definitions across subgraphs
§Example
ⓘ
let subgraphs = vec![
("users".to_string(), users_metadata),
("orders".to_string(), orders_metadata),
];
let validator = CompositionValidator::new();
let composed = validator.validate_composition(subgraphs)?;§Architecture
The composition process works in two phases:
-
Consistency Validation (CrossSubgraphValidator)
- Validates across all subgraphs simultaneously
- Checks federation directives for conflicts
- Collects all errors before returning
-
Schema Composition (CompositionValidator)
- Merges type definitions from all subgraphs
- Errors on type conflicts (safest default)
- Produces final supergraph schema
Structs§
- Composed
Schema - Composed supergraph schema
- Composed
Type - A type in the composed supergraph
- Composition
Validator - Composes multiple subgraph schemas into a supergraph
- Cross
Subgraph Validator - Validator for cross-subgraph federation consistency
Enums§
- Composition
Error - Errors during schema composition
- Conflict
Resolution Strategy - Configuration for schema composition