Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
dotdat committed Nov 8, 2024
1 parent 6f8ea7f commit 8ab5e55
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 29 deletions.
2 changes: 2 additions & 0 deletions src/command/dev/next/router/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ use semver::Version;
#[derive(Clone, Debug)]
#[cfg_attr(test, derive(derive_getters::Getters))]
pub struct RouterBinary {
#[allow(unused)]
exe: Utf8PathBuf,
#[allow(unused)]
version: Version,
}

Expand Down
1 change: 1 addition & 0 deletions src/command/dev/next/router/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub struct InstallRouter {
}

impl InstallRouter {
#[allow(unused)]
pub fn new(
router_version: RouterVersion,
studio_client_config: StudioClientConfig,
Expand Down
40 changes: 17 additions & 23 deletions src/command/supergraph/compose/do_compose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ use crate::{
events::CompositionEvent,
runner::Runner,
supergraph::{
binary::{InstallSupergraph, InstallSupergraphBinary, OutputTarget, SupergraphBinary},
binary::{OutputTarget, SupergraphBinary},
config::{
resolve::{
subgraph::FullyResolvedSubgraph, FullyResolvedSubgraphs,
FullyResolvedSupergraphConfig, UnresolvedSupergraphConfig,
},
SupergraphConfigResolver,
},
install::InstallSupergraph,
version::SupergraphVersion,
},
},
Expand All @@ -57,6 +58,7 @@ use crate::{
effect::{
exec::TokioCommand,
fetch_remote_subgraph::RemoteSubgraph,
install::InstallBinary,
read_file::FsReadFile,
write_file::{FsWriteFile, WriteFile},
},
Expand Down Expand Up @@ -260,31 +262,23 @@ impl Compose {
}

// Build the supergraph binary, paying special attention to the CLI options
let supergraph_binary = InstallSupergraph::builder()
.federation_version(fed_version.clone())
.elv2_license_accepter(self.opts.plugin_opts.elv2_license_accepter)
.studio_client_config(client_config.clone())
.and_override_install_path(override_install_path)
.skip_update(self.opts.plugin_opts.skip_update)
.build()
.install()
let supergraph_binary = InstallSupergraph::new(fed_version.clone(), client_config.clone())
.install(
override_install_path,
self.opts.plugin_opts.elv2_license_accepter,
self.opts.plugin_opts.skip_update,
)
.await?;

// Federation versions and supergraph versions are synonymous, but have different types
// representing them depending on their use (eg, we only ever have an exact
// SupergraphVersion because we can only ever use an exact version of the binary, where the
// FederationVersion can just point to latest to get the latest version--these are similar,
// but represent different ways of using the underlying version)
let supergraph_version: SupergraphVersion = fed_version.clone().try_into()?;

let supergraph_binary = SupergraphBinary::builder()
.exe(supergraph_binary)
.output_target(output_file)
.version(supergraph_version)
.build();

let result = supergraph_binary
.compose(&exec_command, &read_file, supergraph_config_filepath)
.compose(
&exec_command,
&read_file,
&output_file
.map(|path| OutputTarget::File(path))
.unwrap_or_else(|| OutputTarget::Stdout),
supergraph_config_filepath,
)
.await?;

Ok(RoverOutput::CompositionResult(result.into()))
Expand Down
14 changes: 8 additions & 6 deletions src/composition/supergraph/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,26 +213,28 @@ mod tests {
#[rstest]
#[case::exact_fed_one(
FederationVersion::ExactFedOne(fed_one()),
Ok(SupergraphVersion::new(fed_one()))
SupergraphVersion::new(fed_one())
)]
#[case::exact_fed_two(
FederationVersion::ExactFedTwo(fed_two_eight()),
Ok(SupergraphVersion::new(fed_two_eight()))
SupergraphVersion::new(fed_two_eight())
)]
#[case::latest_fed_one(
FederationVersion::LatestFedOne,
Ok(SupergraphVersion::new(latest_fed_one()))
SupergraphVersion::new(latest_fed_one())
)]
#[case::latest_fed_two(
FederationVersion::LatestFedTwo,
Ok(SupergraphVersion::new(latest_fed_two()))
SupergraphVersion::new(latest_fed_two())
)]
fn test_tryfrom_fedversion_for_supergraphversion(
#[case] fed_version: FederationVersion,
#[case] expected: Result<SupergraphVersion, SupergraphVersionError>,
#[case] expected: SupergraphVersion,
) {
let supergraph_version = TryInto::<SupergraphVersion>::try_into(fed_version);
assert_that!(supergraph_version).is_equal_to(expected)
assert_that!(supergraph_version)
.is_ok()
.is_equal_to(expected)
}

#[rstest]
Expand Down

0 comments on commit 8ab5e55

Please sign in to comment.