From 01695b4eb425209f7b766e47ef7f7660c84a304f Mon Sep 17 00:00:00 2001 From: Dylan Anthony Date: Thu, 19 Sep 2024 12:49:21 -0600 Subject: [PATCH] Implement breaking changes for `apollo-federation-types` 0.14 (#2104) Some modules were renamed to better represent what they are for, and some internal cloning was removed. --------- Co-authored-by: Dan --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- crates/rover-client/src/error.rs | 2 +- .../src/operations/subgraph/check_workflow/runner.rs | 2 +- .../rover-client/src/operations/subgraph/delete/runner.rs | 2 +- .../rover-client/src/operations/subgraph/delete/types.rs | 2 +- .../src/operations/subgraph/publish/runner.rs | 2 +- .../rover-client/src/operations/subgraph/publish/types.rs | 2 +- .../src/operations/supergraph/fetch/runner.rs | 4 ++-- src/command/dev/protocol/follower/message.rs | 2 +- src/command/dev/protocol/follower/messenger.rs | 2 +- src/command/dev/protocol/leader.rs | 8 ++++++-- src/command/dev/protocol/types.rs | 2 +- src/command/dev/watcher.rs | 8 ++++++-- src/command/output.rs | 2 +- src/command/supergraph/compose/do_compose.rs | 2 +- src/command/supergraph/compose/mod.rs | 2 +- src/error/mod.rs | 2 +- src/utils/supergraph_config.rs | 2 +- 19 files changed, 31 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e14b0e6e6..59186d005 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -152,9 +152,9 @@ dependencies = [ [[package]] name = "apollo-federation-types" -version = "0.13.2" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd88512dea257880f1e47d5541d14ba8a573b267fdc54af78f1b0bfdd3b73861" +checksum = "5d8899fbf7827589fac6873da085de4a4c5baef1ee9ce9a9a0e8be4370a2849e" dependencies = [ "camino", "log", diff --git a/Cargo.toml b/Cargo.toml index 97e6eebe1..0af4d22f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,7 +69,7 @@ apollo-parser = "0.8" apollo-encoder = "0.8" # https://github.com/apollographql/federation-rs -apollo-federation-types = "0.13.2" +apollo-federation-types = "0.14.0" # crates.io dependencies ariadne = "0.4" diff --git a/crates/rover-client/src/error.rs b/crates/rover-client/src/error.rs index 2608edeba..10fad57ab 100644 --- a/crates/rover-client/src/error.rs +++ b/crates/rover-client/src/error.rs @@ -1,4 +1,4 @@ -use apollo_federation_types::build::BuildErrors; +use apollo_federation_types::rover::BuildErrors; use thiserror::Error; use crate::shared::{CheckTaskStatus, CheckWorkflowResponse, GraphRef, LintResponse}; diff --git a/crates/rover-client/src/operations/subgraph/check_workflow/runner.rs b/crates/rover-client/src/operations/subgraph/check_workflow/runner.rs index a94755487..ac35dd1a1 100644 --- a/crates/rover-client/src/operations/subgraph/check_workflow/runner.rs +++ b/crates/rover-client/src/operations/subgraph/check_workflow/runner.rs @@ -1,6 +1,6 @@ use std::time::{Duration, Instant}; -use apollo_federation_types::build::BuildError; +use apollo_federation_types::rover::BuildError; use graphql_client::*; use crate::blocking::StudioClient; diff --git a/crates/rover-client/src/operations/subgraph/delete/runner.rs b/crates/rover-client/src/operations/subgraph/delete/runner.rs index 324378bd1..faa900fa9 100644 --- a/crates/rover-client/src/operations/subgraph/delete/runner.rs +++ b/crates/rover-client/src/operations/subgraph/delete/runner.rs @@ -3,7 +3,7 @@ use crate::operations::subgraph::delete::types::*; use crate::shared::GraphRef; use crate::RoverClientError; -use apollo_federation_types::build::{BuildError, BuildErrors}; +use apollo_federation_types::rover::{BuildError, BuildErrors}; use graphql_client::*; diff --git a/crates/rover-client/src/operations/subgraph/delete/types.rs b/crates/rover-client/src/operations/subgraph/delete/types.rs index 8f56dd99b..8769a2694 100644 --- a/crates/rover-client/src/operations/subgraph/delete/types.rs +++ b/crates/rover-client/src/operations/subgraph/delete/types.rs @@ -3,7 +3,7 @@ use crate::{operations::subgraph::delete::runner::subgraph_delete_mutation, shar pub(crate) type MutationComposition = subgraph_delete_mutation::SubgraphDeleteMutationGraphRemoveImplementingServiceAndTriggerComposition; pub(crate) type MutationVariables = subgraph_delete_mutation::Variables; -use apollo_federation_types::build::BuildErrors; +use apollo_federation_types::rover::BuildErrors; use serde::Serialize; diff --git a/crates/rover-client/src/operations/subgraph/publish/runner.rs b/crates/rover-client/src/operations/subgraph/publish/runner.rs index bd55d825b..160044419 100644 --- a/crates/rover-client/src/operations/subgraph/publish/runner.rs +++ b/crates/rover-client/src/operations/subgraph/publish/runner.rs @@ -10,7 +10,7 @@ use crate::RoverClientError; use graphql_client::*; -use apollo_federation_types::build::{BuildError, BuildErrors}; +use apollo_federation_types::rover::{BuildError, BuildErrors}; #[derive(GraphQLQuery)] // The paths are relative to the directory where your `Cargo.toml` is located. diff --git a/crates/rover-client/src/operations/subgraph/publish/types.rs b/crates/rover-client/src/operations/subgraph/publish/types.rs index 6500d6674..c73fd5c55 100644 --- a/crates/rover-client/src/operations/subgraph/publish/types.rs +++ b/crates/rover-client/src/operations/subgraph/publish/types.rs @@ -7,7 +7,7 @@ pub(crate) type MutationVariables = subgraph_publish_mutation::Variables; pub(crate) type UpdateResponse = subgraph_publish_mutation::SubgraphPublishMutationGraphPublishSubgraph; -use apollo_federation_types::build::BuildErrors; +use apollo_federation_types::rover::BuildErrors; type SchemaInput = subgraph_publish_mutation::PartialSchemaInput; type GitContextInput = subgraph_publish_mutation::GitContextInput; diff --git a/crates/rover-client/src/operations/supergraph/fetch/runner.rs b/crates/rover-client/src/operations/supergraph/fetch/runner.rs index b96bb295d..3386e6187 100644 --- a/crates/rover-client/src/operations/supergraph/fetch/runner.rs +++ b/crates/rover-client/src/operations/supergraph/fetch/runner.rs @@ -1,4 +1,4 @@ -use apollo_federation_types::build::BuildError; +use apollo_federation_types::rover::BuildError; use graphql_client::*; use crate::blocking::StudioClient; @@ -91,7 +91,7 @@ fn get_supergraph_sdl_from_response_data( #[cfg(test)] mod tests { - use apollo_federation_types::build::BuildErrors; + use apollo_federation_types::rover::BuildErrors; use serde_json::json; use super::*; diff --git a/src/command/dev/protocol/follower/message.rs b/src/command/dev/protocol/follower/message.rs index 11d951bca..3a72ccb67 100644 --- a/src/command/dev/protocol/follower/message.rs +++ b/src/command/dev/protocol/follower/message.rs @@ -1,5 +1,5 @@ use anyhow::anyhow; -use apollo_federation_types::build::SubgraphDefinition; +use apollo_federation_types::javascript::SubgraphDefinition; use serde::{Deserialize, Serialize}; use std::fmt::Debug; diff --git a/src/command/dev/protocol/follower/messenger.rs b/src/command/dev/protocol/follower/messenger.rs index 140fb7a01..f73360dfb 100644 --- a/src/command/dev/protocol/follower/messenger.rs +++ b/src/command/dev/protocol/follower/messenger.rs @@ -1,7 +1,7 @@ use std::{fmt::Debug, io::BufReader, time::Duration}; use anyhow::anyhow; -use apollo_federation_types::build::SubgraphDefinition; +use apollo_federation_types::javascript::SubgraphDefinition; use crossbeam_channel::{Receiver, Sender}; use interprocess::local_socket::traits::Stream; diff --git a/src/command/dev/protocol/leader.rs b/src/command/dev/protocol/leader.rs index d4e2ae6e3..c644336a1 100644 --- a/src/command/dev/protocol/leader.rs +++ b/src/command/dev/protocol/leader.rs @@ -8,8 +8,8 @@ use std::{ use anyhow::{anyhow, Context}; use apollo_federation_types::{ - build::SubgraphDefinition, config::{FederationVersion, SupergraphConfig}, + javascript::SubgraphDefinition, }; use camino::Utf8PathBuf; use crossbeam_channel::{bounded, Receiver, Sender}; @@ -413,7 +413,11 @@ impl LeaderSession { let mut supergraph_config: SupergraphConfig = self .subgraphs .iter() - .map(|((name, url), sdl)| SubgraphDefinition::new(name, url.to_string(), sdl)) + .map(|((name, url), sdl)| SubgraphDefinition { + name: name.clone(), + url: url.to_string(), + sdl: sdl.clone(), + }) .collect::>() .into(); diff --git a/src/command/dev/protocol/types.rs b/src/command/dev/protocol/types.rs index 8bb2b52d6..472b6c470 100644 --- a/src/command/dev/protocol/types.rs +++ b/src/command/dev/protocol/types.rs @@ -1,7 +1,7 @@ use crate::command::supergraph::compose::CompositionOutput; use anyhow::Result; -use apollo_federation_types::build::SubgraphDefinition; +use apollo_federation_types::javascript::SubgraphDefinition; use reqwest::Url; pub type SubgraphName = String; diff --git a/src/command/dev/watcher.rs b/src/command/dev/watcher.rs index 623dc6d31..9dbcc501a 100644 --- a/src/command/dev/watcher.rs +++ b/src/command/dev/watcher.rs @@ -2,7 +2,7 @@ use std::str::FromStr; use std::{collections::HashMap, time::Duration}; use anyhow::{anyhow, Context}; -use apollo_federation_types::build::SubgraphDefinition; +use apollo_federation_types::javascript::SubgraphDefinition; use camino::{Utf8Path, Utf8PathBuf}; use reqwest::Client; use tokio::time::MissedTickBehavior::Delay; @@ -195,7 +195,11 @@ impl SubgraphSchemaWatcher { SubgraphSchemaWatcherKind::Once(sdl) => (sdl.clone(), None), }; - let subgraph_definition = SubgraphDefinition::new(name, url, sdl); + let subgraph_definition = SubgraphDefinition { + name, + url: url.to_string(), + sdl, + }; Ok((subgraph_definition, refresher)) } diff --git a/src/command/output.rs b/src/command/output.rs index 1226d9253..445ff6b0b 100644 --- a/src/command/output.rs +++ b/src/command/output.rs @@ -666,7 +666,7 @@ mod tests { use std::collections::BTreeMap; use anyhow::anyhow; - use apollo_federation_types::build::{BuildError, BuildErrors}; + use apollo_federation_types::rover::{BuildError, BuildErrors}; use assert_json_diff::assert_json_eq; use chrono::{DateTime, Local, Utc}; diff --git a/src/command/supergraph/compose/do_compose.rs b/src/command/supergraph/compose/do_compose.rs index a608a6cd8..b707af7ec 100644 --- a/src/command/supergraph/compose/do_compose.rs +++ b/src/command/supergraph/compose/do_compose.rs @@ -4,8 +4,8 @@ use anyhow::{anyhow, Context}; use apollo_federation_types::config::FederationVersion::LatestFedTwo; use apollo_federation_types::config::SupergraphConfig; use apollo_federation_types::{ - build::BuildResult, config::{FederationVersion, PluginVersion}, + rover::BuildResult, }; use camino::Utf8PathBuf; use clap::{Args, Parser}; diff --git a/src/command/supergraph/compose/mod.rs b/src/command/supergraph/compose/mod.rs index ba822190c..c62164e66 100644 --- a/src/command/supergraph/compose/mod.rs +++ b/src/command/supergraph/compose/mod.rs @@ -10,7 +10,7 @@ mod do_compose; #[cfg(feature = "composition-js")] pub(crate) use do_compose::Compose; -use apollo_federation_types::build::BuildHint; +use apollo_federation_types::rover::BuildHint; #[derive(Debug, Clone, Eq, PartialEq)] pub struct CompositionOutput { diff --git a/src/error/mod.rs b/src/error/mod.rs index 760771aa6..2ed9a0611 100644 --- a/src/error/mod.rs +++ b/src/error/mod.rs @@ -15,7 +15,7 @@ use std::borrow::BorrowMut; use std::error::Error; use std::fmt::{self, Debug, Display}; -use apollo_federation_types::build::BuildErrors; +use apollo_federation_types::rover::BuildErrors; use crate::options::JsonVersion; diff --git a/src/utils/supergraph_config.rs b/src/utils/supergraph_config.rs index c24c23e1e..ecee01591 100644 --- a/src/utils/supergraph_config.rs +++ b/src/utils/supergraph_config.rs @@ -2,10 +2,10 @@ use std::collections::BTreeMap; use std::str::FromStr; use anyhow::anyhow; -use apollo_federation_types::build::{BuildError, BuildErrors}; use apollo_federation_types::config::{ FederationVersion, SchemaSource, SubgraphConfig, SupergraphConfig, }; +use apollo_federation_types::rover::{BuildError, BuildErrors}; use apollo_parser::{cst, Parser}; use futures::future::join_all;