Skip to content

Commit

Permalink
ROVER-245 Update composition to keep routing_urls
Browse files Browse the repository at this point in the history
In the previous version we added nonsense values, but this shouldn't
have worked, and this way is better.
  • Loading branch information
jonathanrainer committed Dec 6, 2024
1 parent df19770 commit eb509d3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/composition/supergraph/config/full/subgraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use crate::{
/// Represents a [`SubgraphConfig`] that has been resolved down to an SDL
#[derive(Clone, Debug, Eq, PartialEq, Getters)]
pub struct FullyResolvedSubgraph {
#[getter(skip)]
routing_url: Option<String>,
schema: String,
is_fed_two: bool,
Expand Down
19 changes: 17 additions & 2 deletions src/composition/watchers/composition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,22 @@ where
SubgraphEvent::SubgraphChanged(subgraph_schema_changed) => {
let name = subgraph_schema_changed.name();
let sdl = subgraph_schema_changed.sdl();
let routing_url = subgraph_schema_changed.routing_url();
// This handling is a bit complex, however the key is two facts:
// - The semantics of watching the SupergraphConfig are such that
// if a routing_url is changed, this constitutes a removal & an add.
// - Any other change to a Schema is limited to it's SDL, not the
// name or routing URL.
//
// With that in mind, if we are not tracking the subgraph already
// then the routing URL must be included in the change event. Thus,
// we can extract it without issue. If that isn't the case then
// it further must be true that the routing URL hasn't changed
// so we can simply extract it and re-use it.
let routing_url = if subgraphs.contains_key(name) {
subgraphs[name].routing_url()
} else {
subgraph_schema_changed.routing_url()
};
if subgraphs
.insert(
name.clone(),
Expand Down Expand Up @@ -88,7 +103,7 @@ where
}
}

let supergraph_config = convert_to_supergraph_config(subgraphs.clone());
let supergraph_config = dbg!(convert_to_supergraph_config(subgraphs.clone()));
let supergraph_config_yaml = serde_yaml::to_string(&supergraph_config);

let supergraph_config_yaml = match supergraph_config_yaml {
Expand Down

0 comments on commit eb509d3

Please sign in to comment.