Skip to content

Conversation

clenfest
Copy link
Contributor

No description provided.

Copy link

changeset-bot bot commented Mar 28, 2025

⚠️ No Changeset found

Latest commit: 2020c89

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

@svc-apollo-docs
Copy link
Collaborator

svc-apollo-docs commented Mar 28, 2025

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: 1787e33aa6a2f47793ff66c2

Copy link

codesandbox-ci bot commented Apr 8, 2025

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.

@clenfest clenfest marked this pull request as ready for review April 8, 2025 18:02
@clenfest clenfest requested a review from a team as a code owner April 8, 2025 18:02
sdlPrintOptions?: PrintOptions;
allowedFieldTypeMergingSubtypingRules?: SubtypingRule[];
/// Flag to toggle if satisfiability should be performed during composition
runSatisfiability?: boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would be a breaking change.... but ideally this should move under new pipelineOptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be a breaking change to add an extra optional field to the return type?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if was thinking about moving this over but yeah if we also add extra option there then yeah that should be fine (and IMHO more consistent, maybe we could deprecate the old field as well)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, which old field do you mean?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move runSatisfiability?: boolean; under new pipelineOptions

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my other comment though as I think this PR might not be that useful from hybrid composition perspective

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this PR would make it possible to support the future HybridComposition. Can federation-rs call composition with the piplineOptions to achieve the goals, no? 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of -> using pipeline options would enable us to skip first or last stages but will not allow pick and choose style of integrations.

i.e. given following stages

  pipelineOptions?: {
    runUpgradeSubgraphs?: boolean;
    runValidateSubgraphs?: boolean;
    runComposition?: boolean;
    runSatisfiability?: boolean;
    outputUpgradedSubgraphs?: boolean;
  }

How would you integrate it with hybrid composition if you only want to replace subgraph validations with Rust version? Or if you just want to compare single phases?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could move it, but I was thinking that runSatisfiability will be more long lived, but the other ones are really only for our use and will be temporary.

@dariuszkuc
Copy link
Member

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>
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants