From 91bbdc68b211ecf218245b58ec2b7677cb91d371 Mon Sep 17 00:00:00 2001 From: jonathanrainer Date: Sun, 24 Nov 2024 08:49:49 +0000 Subject: [PATCH] ROVER-245 Fix two small buglets The first is that we weren't supplying the correct content root for the supergraph.yaml. The second is that we need to have a value of the routing URLm, even if it's not used, when it goes to the supergraph.yaml --- src/command/lsp/mod.rs | 10 +++------- src/composition/supergraph/config/resolve/mod.rs | 5 ++++- src/composition/supergraph/config/resolve/subgraph.rs | 3 +++ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/command/lsp/mod.rs b/src/command/lsp/mod.rs index 0ba3fd4f4..405779d36 100644 --- a/src/command/lsp/mod.rs +++ b/src/command/lsp/mod.rs @@ -78,6 +78,7 @@ async fn run_lsp(client_config: StudioClientConfig, lsp_opts: LspOpts) -> RoverR } }) .ok_or_else(|| anyhow!("Could not find supergraph.yaml file."))?; + let supergraph_content_root = supergraph_yaml_path.parent().unwrap().to_path_buf(); let studio_client = client_config.get_authenticated_client(&lsp_opts.plugin_opts.profile)?; @@ -90,18 +91,13 @@ async fn run_lsp(client_config: StudioClientConfig, lsp_opts: LspOpts) -> RoverR Some(&FileDescriptorType::File(supergraph_yaml_path.clone())), )?; let lazily_resolved_supergraph_config = supergraph_config - .lazily_resolve_subgraphs(&supergraph_yaml_path) + .lazily_resolve_subgraphs(&supergraph_content_root) .await?; - let root_uri = supergraph_yaml_path - .parent() - .map(|path| path.to_string()) - .unwrap_or_default(); - // Build the service to spin up the language server let (service, socket, _receiver) = ApolloLanguageServer::build_service( Config { - root_uri, + root_uri: supergraph_content_root.to_string(), enable_auto_composition: false, force_federation: false, disable_telemetry: false, diff --git a/src/composition/supergraph/config/resolve/mod.rs b/src/composition/supergraph/config/resolve/mod.rs index 28a99983f..9d5264ebb 100644 --- a/src/composition/supergraph/config/resolve/mod.rs +++ b/src/composition/supergraph/config/resolve/mod.rs @@ -299,7 +299,10 @@ impl From for SupergraphConfig { ( name, SubgraphConfig { - routing_url: None, + // This value is effectively unused but has to be set to something that + // is not "null" when serialised otherwise the supergraph binary + // complains + routing_url: Some(String::from("localhost")), schema: SchemaSource::Sdl { sdl }, }, ) diff --git a/src/composition/supergraph/config/resolve/subgraph.rs b/src/composition/supergraph/config/resolve/subgraph.rs index 74bf49fff..597789764 100644 --- a/src/composition/supergraph/config/resolve/subgraph.rs +++ b/src/composition/supergraph/config/resolve/subgraph.rs @@ -28,6 +28,8 @@ pub enum ResolveSubgraphError { supergraph_config_path: Utf8PathBuf, /// Supplied path to the subgraph schema file path: PathBuf, + /// The result of joining the paths together, that caused the failure + joined_path: PathBuf, /// The source error source: std::io::Error, }, @@ -97,6 +99,7 @@ impl UnresolvedSubgraph { subgraph_name: self.name.to_string(), supergraph_config_path: root.clone(), path: path.as_std_path().to_path_buf(), + joined_path: joined_path.as_std_path().to_path_buf(), source: err, }), }