Skip to content

fix graphman deploy command logic when creating subgraph #5740

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 1 addition & 6 deletions node/src/bin/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,6 @@ pub enum Command {
/// The url of the graph-node
#[clap(long, short, default_value = "http://localhost:8020")]
url: String,

/// Create the subgraph name if it does not exist
#[clap(long, short)]
create: bool,
},
}

Expand Down Expand Up @@ -1637,12 +1633,11 @@ async fn main() -> anyhow::Result<()> {
deployment,
name,
url,
create,
} => {
let store = ctx.store();
let subgraph_store = store.subgraph_store();

commands::deploy::run(subgraph_store, deployment, name, url, create).await
commands::deploy::run(subgraph_store, deployment, name, url).await
}
}
}
Expand Down
14 changes: 5 additions & 9 deletions node/src/manager/commands/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ pub async fn run(
deployment: DeploymentSearch,
search: DeploymentSearch,
url: String,
create: bool,
) -> Result<()> {
let hash = match deployment {
DeploymentSearch::Hash { hash, shard: _ } => hash,
Expand All @@ -80,16 +79,13 @@ pub async fn run(
_ => bail!("The `name` must be a valid subgraph name"),
};

if create {
println!("Creating subgraph `{}`", name);
let subgraph_name =
SubgraphName::new(name.clone()).map_err(|_| anyhow!("Invalid subgraph name"))?;
let subgraph_name =
SubgraphName::new(name.clone()).map_err(|_| anyhow!("Invalid subgraph name"))?;

let exists = subgraph_store.subgraph_exists(&subgraph_name)?;
let exists = subgraph_store.subgraph_exists(&subgraph_name)?;

if exists {
bail!("Subgraph with name `{}` already exists", name);
}
if !exists {
println!("Creating subgraph `{}`", name);

// Send the subgraph_create request
send_create_request(&name, &url).await?;
Expand Down
Loading