Skip to content

Commit

Permalink
ROVER-245 Address PR comments and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanrainer committed Dec 9, 2024
1 parent 4013ac7 commit c1d3e8a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 30 deletions.
32 changes: 17 additions & 15 deletions src/command/lsp/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
use futures::StreamExt;
mod errors;

use std::collections::HashMap;
use std::env::temp_dir;
use std::io::stdin;

use anyhow::{anyhow, Error};
use apollo_federation_types::config::FederationVersion;
use apollo_language_server::{ApolloLanguageServer, Config};
use camino::Utf8PathBuf;
use clap::Parser;
use futures::StreamExt;
use rover_client::blocking::StudioClient;
use serde::Serialize;
use tower_lsp::lsp_types::{Diagnostic, Range};
use tower_lsp::Server;
use tracing::debug;
use url::Url;

use crate::command::lsp::errors::SupergraphConfigLazyResolutionError;
use crate::command::lsp::errors::SupergraphConfigLazyResolutionError::PathDoesNotPointToAFile;
use crate::composition::events::CompositionEvent;
Expand All @@ -23,20 +39,6 @@ use crate::{
utils::{client::StudioClientConfig, parsers::FileDescriptorType},
RoverOutput, RoverResult,
};
use anyhow::{anyhow, Error};
use apollo_federation_types::config::FederationVersion;
use apollo_language_server::{ApolloLanguageServer, Config};
use camino::Utf8PathBuf;
use clap::Parser;
use rover_client::blocking::StudioClient;
use serde::Serialize;
use std::collections::HashMap;
use std::env::temp_dir;
use std::io::stdin;
use tower_lsp::lsp_types::{Diagnostic, Range};
use tower_lsp::Server;
use tracing::debug;
use url::Url;

#[derive(Debug, Serialize, Parser)]
pub struct Lsp {
Expand Down
9 changes: 4 additions & 5 deletions src/command/supergraph/compose/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ pub(crate) use no_compose::Compose;
#[cfg(feature = "composition-js")]
pub(crate) mod do_compose;

use apollo_federation_types::rover::BuildHint;
#[cfg(feature = "composition-js")]
pub(crate) use do_compose::Compose;

#[cfg(feature = "composition-js")]
use crate::composition::CompositionSuccess;

use apollo_federation_types::rover::BuildHint;

#[derive(Debug, Clone, Eq, PartialEq)]
pub struct CompositionOutput {
pub supergraph_sdl: String,
Expand All @@ -29,9 +28,9 @@ pub struct CompositionOutput {
impl From<CompositionSuccess> for CompositionOutput {
fn from(value: CompositionSuccess) -> Self {
Self {
supergraph_sdl: value.supergraph_sdl().clone(),
hints: value.hints().to_vec(),
federation_version: Some(value.federation_version().to_string()),
supergraph_sdl: value.supergraph_sdl.clone(),
hints: value.hints.to_vec(),
federation_version: Some(value.federation_version.to_string()),
}
}
}
9 changes: 4 additions & 5 deletions src/composition/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use apollo_federation_types::{
rover::{BuildErrors, BuildHint},
};
use camino::Utf8PathBuf;
use derive_getters::Getters;

pub mod events;
pub mod runner;
Expand All @@ -18,11 +17,11 @@ pub mod types;
#[cfg(feature = "composition-js")]
mod watchers;

#[derive(Getters, Debug, Clone, Eq, PartialEq)]
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct CompositionSuccess {
pub(crate) supergraph_sdl: String,
pub(crate) hints: Vec<BuildHint>,
pub(crate) federation_version: FederationVersion,
pub supergraph_sdl: String,
pub hints: Vec<BuildHint>,
pub federation_version: FederationVersion,
}

#[derive(thiserror::Error, Debug, Eq, PartialEq)]
Expand Down
9 changes: 4 additions & 5 deletions src/composition/watchers/watcher/supergraph_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ use rover_std::errln;
use tap::TapFallible;
use tokio::{sync::mpsc::UnboundedSender, task::AbortHandle};

use super::file::FileWatcher;
use crate::{
composition::supergraph::config::lazy::LazilyResolvedSupergraphConfig,
subtask::SubtaskHandleUnit,
};

use super::file::FileWatcher;

#[derive(Debug)]
pub struct SupergraphConfigWatcher {
file_watcher: FileWatcher,
Expand Down Expand Up @@ -98,8 +97,8 @@ impl SupergraphConfigDiff {
.collect();

// Compare the old and new subgraph names to find removals.
let removed_names: HashSet<String> = new_subgraph_names_and_urls
.difference(&old_subgraph_names_and_urls)
let removed_names: HashSet<String> = old_subgraph_names_and_urls
.difference(&new_subgraph_names_and_urls)
.map(|(a, _)| a.clone())
.collect();

Expand Down Expand Up @@ -138,10 +137,10 @@ impl SupergraphConfigDiff {

#[cfg(test)]
mod tests {
use rstest::rstest;
use std::collections::BTreeMap;

use apollo_federation_types::config::{SchemaSource, SubgraphConfig, SupergraphConfig};
use rstest::rstest;

use super::SupergraphConfigDiff;

Expand Down

0 comments on commit c1d3e8a

Please sign in to comment.