Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow rover dev to utilise watching again #2065

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/command/dev/do_dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ impl Dev {
.unwrap_or(FederationVersion::LatestFedTwo),
client_config.clone(),
&self.opts.plugin_opts.profile,
false,
)
.await?;

Expand Down
1 change: 1 addition & 0 deletions src/command/supergraph/compose/do_compose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ impl Compose {
&self.opts.federation_version.clone().unwrap_or(LatestFedTwo),
client_config.clone(),
&self.opts.plugin_opts.profile,
true,
)
.await?
// WARNING: remove this unwrap
Expand Down
23 changes: 19 additions & 4 deletions src/utils/supergraph_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ pub async fn get_supergraph_config(
federation_version: &FederationVersion,
client_config: StudioClientConfig,
profile_opt: &ProfileOpt,
create_static_config: bool,
) -> Result<Option<SupergraphConfig>, RoverError> {
// Read in Remote subgraphs
let remote_subgraphs = match graph_ref {
Expand All @@ -75,11 +76,23 @@ pub async fn get_supergraph_config(
}
None => None,
};

// Read in Local Supergraph Config
let supergraph_config = if let Some(file_descriptor) = &supergraph_config_path {
eprintln!("resolving SDL for subgraphs defined in supergraph schema file",);
Some(resolve_supergraph_yaml(file_descriptor, client_config, profile_opt).await?)
// Depending on the context we might want two slightly different kinds of SupergraphConfig.
if create_static_config {
// In this branch we get a completely resolved config, so all the references in it are
// resolved to a concrete SDL that could be printed out to a user. This is what
// `supergraph compose` uses.
Some(resolve_supergraph_yaml(file_descriptor, client_config, profile_opt).await?)
} else {
// Alternatively, we might actually want a more dynamic object so that we can
// set up watchers on the subgraph sources. This branch is what `rover dev` uses.
// So we run the `expand` function only to hydrate the YAML into a series of objects,
// but we don't need to completely resolve all of those objects.
let config = file_descriptor
.read_file_descriptor("supergraph config", &mut std::io::stdin())
.and_then(|contents| expand_supergraph_yaml(&contents))?;
Some(config)
}
} else {
None
};
Expand Down Expand Up @@ -330,6 +343,7 @@ mod test_get_supergraph_config {
latest_fed2_version,
studio_client_config,
&profile_opt,
true,
)
.await
.expect("Could not construct SupergraphConfig")
Expand All @@ -340,6 +354,7 @@ mod test_get_supergraph_config {
latest_fed2_version,
studio_client_config,
&profile_opt,
true,
)
.await
.expect("Could not construct SupergraphConfig")
Expand Down
Loading