Route registry selection through one shared query_entries_for

The "which queries: block applies for graph X" rule existed twice — the
server boot path and the CLI's registry_entries — and had already drifted:
the CLI carried an unreachable unwrap_or_else fallback the server lacked.

Add OmnigraphConfig::query_entries_for(graph: Option<&str>) as the single
definition (named graph -> its per-graph block; otherwise top-level) and
route all three sites through it: server single mode, server multi-graph
loop, and the CLI. The CLI's dead fallback arm is deleted; CLI and server
now resolve identically by construction.

No behavior change. Extends the config round-trip test to pin the selector,
including the unknown-name -> top-level fallback the deleted CLI arm covered.
This commit is contained in:
Ragnor Comerford 2026-05-30 21:53:07 +02:00
parent a8f98d4ddc
commit b47e3bbc70
No known key found for this signature in database
3 changed files with 33 additions and 13 deletions

View file

@ -1679,19 +1679,15 @@ struct QueriesListOutput {
queries: Vec<QueriesListItem>,
}
/// Resolve the stored-query registry entries for the selected graph,
/// mirroring the server: a named graph in `graphs:` uses its per-graph
/// `queries:`; otherwise the top-level `queries:` (single-graph mode).
/// Resolve the stored-query registry entries for the selected graph via
/// the same `query_entries_for` the server boot uses, so the CLI
/// validates exactly the block the server would load. A `--target`
/// overrides the configured default graph.
fn registry_entries<'a>(
config: &'a OmnigraphConfig,
target: Option<&str>,
) -> &'a std::collections::BTreeMap<String, omnigraph_server::config::QueryEntry> {
match target.or_else(|| config.cli_graph_name()) {
Some(name) if config.graphs.contains_key(name) => config
.target_query_entries(name)
.unwrap_or_else(|| config.query_entries()),
_ => config.query_entries(),
}
config.query_entries_for(target.or_else(|| config.cli_graph_name()))
}
fn load_registry_or_report(config: &OmnigraphConfig, target: Option<&str>) -> Result<QueryRegistry> {