Add composition options to be able to ignore parts of the composition pipeline
⚠️ No Changeset found
Latest commit: 2020c8949141b0b50f3a799a52df7aaccaf87046
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
✅ Docs preview has no changes
The preview was not built because there were no changes.
Build ID: 1787e33aa6a2f47793ff66c2
This pull request is automatically built and testable in CodeSandbox.
To see build info of the built libraries, click here or the icon next to each commit SHA.
Was thinking about this more and I am unsure whether this will be that useful, i.e. in federation-rs we currently define HybridComposition trait (skipping stuff to make it simpler)
pub trait HybridComposition {
/// Call the JavaScript `composeServices` function from `@apollo/composition` plus whatever
/// extra logic you need. Make sure to disable satisfiability, like `composeServices(definitions, {runSatisfiability: false})`
async fn compose_services_without_satisfiability(
&mut self,
subgraph_definitions: Vec<SubgraphDefinition>,
) -> Option<SupergraphSdl>;
/// Call the JavaScript `validateSatisfiability` function from `@apollo/composition` plus whatever
/// extra logic you need.
async fn validate_satisfiability(&mut self) -> Result<SatisfiabilityResult, Issue>;
/// Allows the Rust composition code to modify the stored supergraph SDL
/// (for example, to expand connectors).
fn update_supergraph_sdl(&mut self, supergraph_sdl: String);
fn add_issues<Source: Iterator<Item = Issue>>(&mut self, issues: Source);
/// Runs the complete composition process, hooking into both the Rust and JavaScript implementations.
///
/// # Algorithm
///
/// 1. Run Rust-based connector validation on the subgraphs
/// 2. Call [`compose_services_without_satisfiability`] to run JavaScript-based composition
/// 3. Run Rust-based connector validation on the supergraph
/// 4. Call [`validate_satisfiability`] to run JavaScript-based validation on the supergraph
async fn compose(&mut self, subgraph_definitions: Vec<SubgraphDefinition>) {
// default impl goes here
}
}
I think in order to make it usable as pick&choose from the trait we would need to update composition to expose those individual stages so we can easily call those functions directly, i.e.
pub trait HybridComposition {
fn process_subgraphs(&mut self, subgraph_definitions: Vec<Subgraph<Raw>>) -> Vec<Subgraph<Expanded>>;
fn validate_subgraphs(&mut self, subgraph_definitions: Vec<Subgraph<Expanded>>) -> Vec<Subgraph<Validated>>;
fn merge(&mut self, Vec<Subgraph<Validated>>) -> Supergraph<Raw>;
fn validate_satisfiability(&mut self, Supergraph<Raw>) -> Supergraph<Validated>;
fn compose(&mut self, subgraph_definitions: Vec<SubgraphDefinition>) {
// default impl goes here -> I think this should return Supergraph<Validated>
}
}