Skip to content

feat(federation/composition): SingleCompositionError #7590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

TylerBloom
Copy link
Contributor

@TylerBloom TylerBloom commented May 29, 2025

This PR splits out the SubgraphError variant of SingleFederationError into a new enum, SingleCompositionError. This includes a conversion from SubgraphError to SingleCompositionError but not from FederationError/SingleFederationError. This is to ensure all federation errors that are intended to be SubgraphErrors do. Lastly, any function that was returning a vec of (single) federation errors is now returning a Vec<SingleCompositionError>


Checklist

Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.

  • Changes are compatible1
  • Documentation2 completed
  • Performance impact assessed and acceptable
  • Metrics and logs are added3 and documented
  • Tests added and passing4
    • Unit Tests
    • Integration Tests
    • Manual Tests

Exceptions

Note any exceptions here

Notes

Footnotes

  1. It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this.

  2. Configuration is an important part of many changes. Where applicable please try to document configuration examples.

  3. A lot of (if not most) features benefit from built-in observability and debug-level logs. Please read this guidance on metrics best-practices.

  4. Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.

@TylerBloom TylerBloom requested review from a team as code owners May 29, 2025 22:37
Copy link
Contributor

@TylerBloom, please consider creating a changeset entry in /.changesets/. These instructions describe the process and tooling.

@svc-apollo-docs
Copy link
Collaborator

svc-apollo-docs commented May 29, 2025

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: 7044316798c0acb71580739d

@@ -114,6 +115,48 @@ pub enum UnsupportedFeatureKind {
Alias,
}

#[derive(Debug, Clone, thiserror::Error)]
pub enum SingleCompositionError {
Copy link
Member

Choose a reason for hiding this comment

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

I was under impression that we don't want to preserve the existing Single/Multi/Aggregate federation error enum. I thought we just want a CompositionError and return a vec if we need multiple errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are correct. That is our long term goal, but removing the multiple fed error variants is a lot of work. At one point in build_query_plan, we could get multiple errors (it's very early on). Fixing that is outside the scope of this ticket, so removing the two multiple fed errors variants is too.

We are using MultipleFederationErrors in composition code. I can replace those with a Vec of composition errors, but those are currently being converted into a SubgraphError and then into a composition error. This largely happens in the upgrade and validation code.

I think the final goal is to identify the subset of errors that might get turned into SubgraphError and use that error type in the locations I mentioned above. Then, merging and satisfiability can add to SingleCompositionError and the errors that need to be SubgraphErrors can be. I think this should be a follow up PR, though.

Copy link
Member

Choose a reason for hiding this comment

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

Should we just start with CompositionError and tackle the MultipleFederationErrors later on?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should, and that's my goal here. What I don't think we can do (yet) is have upgrade and validate use composition errors inside of MultipleFederationErrors. Otherwise, you end up with the same recursive error problem with SubgraphError I got rid of here.

@clenfest
Copy link
Contributor

clenfest commented Jun 2, 2025

Probably should make changes to the src/merger/* code as well.

@@ -361,7 +361,6 @@ fn add_requires_error(
application: requires_application.to_string(),
message,
}
.add_subgraph(subgraph_name.to_owned())
Copy link
Contributor

Choose a reason for hiding this comment

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

We should create a ticket to add this subgraph info back in later (I'm guessing it'll happen when the errors argument changes to a vector of composition errors).

@duckki
Copy link
Contributor

duckki commented Jun 3, 2025

There is a lint error.

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

Successfully merging this pull request may close these issues.

6 participants