graph-tooling icon indicating copy to clipboard operation
graph-tooling copied to clipboard

Allow network `localhost` during `graph init`

Open schmidsi opened this issue 1 year ago • 7 comments

When I try to initialize a subgraph, I'm forced to select a public chain from the registry. It's a pretty common use-case to start developing a subgraph against a local hardhat/anvil node.

$ graph init
 ›   Warning: In next major version, this flag will be removed. By default we will
 ›   stop initializing a Git repository.
? Network … localhost
Other · other network not on the list
< 112 more - type to filter >

Selecting other exits the wizard:

graph init
 ›   Warning: In next major version, this flag will be removed. By default we will
 ›   stop initializing a Git repository.
✔ Network · N/A

  The chain list is populated from the Networks Registry:

  https://github.com/graphprotocol/networks-registry

  To add a chain to the registry you can create an issue or submit a PR

schmidsi avatar Dec 18 '24 13:12 schmidsi

It should continue the flow but forcing to specify a path to an ABI file instead of trying to download the ABI from a blockexplorer in my opinion.

schmidsi avatar Dec 18 '24 13:12 schmidsi

Good point. I like having "Other" option that gives you a way out if you can't find the chain you are looking for. From UX perspective.
Perhaps we can add "Local Node" as an option here.

YaroShkvorets avatar Dec 18 '24 15:12 YaroShkvorets

Just checked earlier versions of graph cli and not seeing "localhost" option. How was it handled before?

YaroShkvorets avatar Dec 18 '24 15:12 YaroShkvorets

It wasn't. It's a new feature request.

schmidsi avatar Dec 18 '24 15:12 schmidsi

Based on further discussions with @p-diogo the flow should go like this:

  1. User selects "Other" or "Custom" network
  2. Enters custom network ID with default being "localhost"
  3. Gets a warning with a suggestion to add this network to the registry
  4. Manually specifies ABI path, start block and contract name

YaroShkvorets avatar Jan 13 '25 15:01 YaroShkvorets

I think it would also be useful to specify a protocol (like ethereum) with a custom RPC. This could be useful if you're running a permissioned (therefore not a well known) network.

anilhelvaci avatar Apr 07 '25 21:04 anilhelvaci

Yup. I need that to be to handle locally run test network like https://0xspaceshard.github.io/starknet-devnet/

Is there any alternative at the moment?

Without it, it just means I cannot use the same indexer for my CI, test and for my production release. Which to me is a deal breaker. I don't want to have to support two indexers for the same chain.

tdelabro avatar Jul 09 '25 20:07 tdelabro