Skip to content

Commit 88a5c0d

Browse files
committed
gnd: Run codegen after init --from-contract
Call run_codegen directly after dependency installation so that init --from-contract produces a ready-to-build subgraph, matching the existing behavior of init --from-example.
1 parent 3d745b3 commit 88a5c0d

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

gnd/src/commands/init.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use clap::{Parser, ValueEnum};
1818
use graphql_parser::schema as gql;
1919

2020
use crate::commands::add::{run_add, AddOpt};
21+
use crate::commands::codegen::{run_codegen, CodegenOpt};
2122
use crate::config::networks::update_networks_file;
2223
use crate::output::{step, with_spinner, Step};
2324
use crate::prompt::{
@@ -390,6 +391,20 @@ async fn init_from_contract(opt: &InitOpt, prefetched: Option<ContractInfo>) ->
390391
}
391392
}
392393

394+
// Run codegen to generate types (requires dependencies to be installed)
395+
if !opt.skip_install {
396+
let codegen_opt = CodegenOpt {
397+
manifest: directory.join("subgraph.yaml"),
398+
output_dir: directory.join("generated"),
399+
skip_migrations: true,
400+
watch: false,
401+
ipfs: "https://api.thegraph.com/ipfs/api/v0".to_string(),
402+
};
403+
if let Err(e) = run_codegen(codegen_opt).await {
404+
eprintln!("Warning: codegen failed: {}", e);
405+
}
406+
}
407+
393408
step(
394409
Step::Done,
395410
&format!("Subgraph created at {}", directory.display()),

0 commit comments

Comments
 (0)