Skip to content

gnd: Add gnd indexer command that delegates to graph-indexer#6492

Open
dimitrovmaksim wants to merge 1 commit intographprotocol:masterfrom
dimitrovmaksim:gnd/add-external-indexer-command
Open

gnd: Add gnd indexer command that delegates to graph-indexer#6492
dimitrovmaksim wants to merge 1 commit intographprotocol:masterfrom
dimitrovmaksim:gnd/add-external-indexer-command

Conversation

@dimitrovmaksim
Copy link
Copy Markdown
Member

@dimitrovmaksim dimitrovmaksim commented Apr 8, 2026

What this PR does:

Adds gnd indexer command that delegates to graph-indexer (@graphprotocol/indexer-cli), allowing users to manage indexer operations (allocations, rules, cost models, status, etc.) directly through gnd. graph-indexer previously integrated into graph-cli as plugin, but now that integration seems to be broken.

Design decisions

Why not clap's external_subcommand?

Clap's external_subcommand attribute is a catch-all that captures any unrecognized subcommand into a Vec. Unlike cargo's external subcommand convention (cargo fmt → cargo-fmt) or Gluegun's plugin system (which auto-discovers and loads plugins at runtime), clap's external_subcommand doesn't perform any binary resolution — it just captures raw args and leaves dispatch to you.

I considered using it but chose an explicit Indexer variant instead because:

  • Command hints: clap will provide hint for similar commands on mistyped named variants but not for the external_subcommand catch-all.
  • Scoped delegation: We only need to delegate to graph-indexer. A catch-all would accept any unknown subcommand and produce confusing "binary not found" errors for typos.

Gluegun namespace prefix

graph-indexer uses Gluegun's plugin system where indexer is the plugin namespace. All management commands require graph-indexer indexer <subcommand> (e.g. graph-indexer indexer allocations get). We prepend indexer automatically so users write gnd indexer allocations get instead of the longer form.

Exceptions:

version/v/--version/-v and help/h are top-level commands in graph-indexer and are forwarded without the indexer prefix.

Help delegation: --help vs help

There are two help paths with different behavior:

gnd indexer --help vs gnd indexer help
  • --help is intercepted by clap before args reach run_indexer(). This is intentional as it provides basic usage information even when graph-indexer is not installed.
  • help (without dashes) passes through to graph-indexer and shows the full command list.

No-args handling

When gnd indexer is invoked with no arguments, we pass help to graph-indexer to show its top-level help.

Exit codes

Exit codes from graph-indexer are passed through as-is, which may differ from gnd's documented 0/1 convention. This is documented in the migration guide. Reason is to not breake existing scripts that may await the current exit codes.

Adds an `Indexer` subcommand to gnd that forwards commands to the
`graph-indexer` binary from the `indexer-cli` npm package. This lets
users run indexer management commands (allocations, rules, cost models,
etc.) directly through gnd.

- `version`, `help` and their short forms are forwarded as top-level
  commands; all other subcommands get the `indexer` namespace prepended
  (required by graph-indexer's Gluegun plugin system)
- `--help` is handled by clap (works without graph-indexer installed)
- On Unix, uses exec() for clean signal forwarding and exit codes
- Clear error message when graph-indexer is not on $PATH
@dimitrovmaksim dimitrovmaksim force-pushed the gnd/add-external-indexer-command branch from 5bf56ef to 6023470 Compare April 8, 2026 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant