Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Second half of updating federation-next to use apollo-compiler@1.0.0-beta.6 #86

Merged
merged 2 commits into from
Nov 13, 2023

Conversation

sachindshinde
Copy link
Contributor

@sachindshinde sachindshinde commented Nov 13, 2023

This PR is the second half of #85 , and fully updates federation-next to work with apollo-compiler@1.0.0-beta.6.

Some notes:

  • This is mainly replacing &str with Name, and converting some functions to use Results.
  • The other notable changes are that types (e.g. ObjectType) need a name field now (making it consistent with the rest of the schema elements in apollo-rs), and some minor renames.
  • Clippy warns that since NodeStr doesn't have #[derive(PartialEq, Eq)], then we can't use Name in pattern-matching; I've worked around it with an enum and map for now.
  • Consolidated a bit of the logic around converting subgraph names to enum values, with a TODO around doing what the JS codebase does.
  • Unrelated, but I've been told we had some usages of .eq() in the Rust code, so I've converted them to ==.

@sachindshinde sachindshinde force-pushed the sachin/apollo-compiler@1.0.0-beta.6-part-2 branch from 9723442 to 7ab7ab5 Compare November 13, 2023 06:48
@@ -53,6 +53,12 @@ impl From<FederationSpecError> for SubgraphError {
}
}

pub(crate) fn graphql_name_or_subgraph_error(name: &str) -> Result<Name, SubgraphError> {
Copy link
Contributor

Choose a reason for hiding this comment

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

The ? operator converts between error types implicitly, so this function can be replaced with impl From<InvalidNameError> for SubgraphError.

… except InvalidNameError does not contain the input string, but we can fix that in apollo-compiler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that was the main reason I didn't just impl From<InvalidNameError> for the error kinds. Added some TODOs there, lemme know when InvalidNameError is updated and I'll make the switch!

@sachindshinde sachindshinde force-pushed the sachin/apollo-compiler@1.0.0-beta.6-part-2 branch from 04896dc to af1d32d Compare November 13, 2023 13:54
@sachindshinde sachindshinde merged commit 88a1efe into main Nov 13, 2023
@sachindshinde sachindshinde deleted the sachin/apollo-compiler@1.0.0-beta.6-part-2 branch November 13, 2023 13:56
SimonSapin pushed a commit to apollographql/router that referenced this pull request May 3, 2024
….0-beta.6` (apollographql/federation-next#86)

This PR is the second half of apollographql/federation-next#85 , and fully updates `federation-next` to work with `apollo-compiler@1.0.0-beta.6`.

Some notes:
- This is mainly replacing `&str` with `Name`, and converting some functions to use `Result`s.
- The other notable changes are that types (e.g. `ObjectType`) need a `name` field now (making it consistent with the rest of the schema elements in `apollo-rs`), and some minor renames.
- Clippy warns that since `NodeStr` doesn't have `#[derive(PartialEq, Eq)]`, then we can't use `Name` in pattern-matching; I've worked around it with an enum and map for now.
- Consolidated a bit of the logic around converting subgraph names to enum values, with a `TODO` around doing what the JS codebase does.
- Unrelated, but I've been told we had some usages of `.eq()` in the Rust code, so I've converted them to `==`.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants