mirror of
https://github.com/ModernRelay/omnigraph.git
synced 2026-06-24 02:38:06 +02:00
feat(MR-656): inline query strings in CLI and HTTP server
CLI: - Add -e / --query-string <STRING> to omnigraph read and omnigraph change - Exactly one of --query, --query-string, --alias is required (3-way XOR) - Empty --query-string is rejected with a clear error HTTP: - New POST /query (read-only, clean field names: query/name/params/branch/snapshot) - Mutations on /query are rejected with 400 -- use POST /change instead - ChangeRequest fields polished: query (alias query_source), name (alias query_name) - POST /read and POST /change remain byte-compatible for existing clients Tests: - cli.rs: -e happy-path on read/change, mutex error vs --query, empty -e rejected - system_local.rs: inline -e read and -e change exercise the local flow - system_remote.rs: inline -e read/change over HTTP plus direct /query 200/400 - server.rs: /query 200, /query 400 on mutation, /change legacy field alias - openapi.rs: new /query path, QueryRequest schema, ChangeRequest field-name polish Docs: cli.md (-e examples), cli-reference.md (read/change rows), server.md (/query) Co-Authored-By: Ragnor Comerford <ragnor.comerford@gmail.com>
This commit is contained in:
parent
aadfa11ecb
commit
4152d9d5dc
14 changed files with 708 additions and 75 deletions
|
|
@ -246,6 +246,37 @@ fn local_cli_end_to_end_init_load_read_change_read_flow() {
|
|||
));
|
||||
assert_eq!(read_after["row_count"], 1);
|
||||
assert_eq!(read_after["rows"][0]["p.name"], "Eve");
|
||||
|
||||
// Inline-source variants of the same read/change flow (CLI `-e` /
|
||||
// `--query-string`). Confirms that file-less invocations reach the
|
||||
// engine identically, including param binding and `branch=main` defaults.
|
||||
let inline_change = parse_stdout_json(&output_success(
|
||||
cli()
|
||||
.arg("change")
|
||||
.arg(repo.path())
|
||||
.arg("-e")
|
||||
.arg("query add($name: String, $age: I32) { insert Person { name: $name, age: $age } }")
|
||||
.arg("--params")
|
||||
.arg(r#"{"name":"Inline","age":42}"#)
|
||||
.arg("--json"),
|
||||
));
|
||||
assert_eq!(inline_change["branch"], "main");
|
||||
assert_eq!(inline_change["query_name"], "add");
|
||||
assert_eq!(inline_change["affected_nodes"], 1);
|
||||
|
||||
let inline_read = parse_stdout_json(&output_success(
|
||||
cli()
|
||||
.arg("read")
|
||||
.arg(repo.path())
|
||||
.arg("--query-string")
|
||||
.arg("query find($name: String) { match { $p: Person { name: $name } } return { $p.name, $p.age } }")
|
||||
.arg("--params")
|
||||
.arg(r#"{"name":"Inline"}"#)
|
||||
.arg("--json"),
|
||||
));
|
||||
assert_eq!(inline_read["row_count"], 1);
|
||||
assert_eq!(inline_read["rows"][0]["p.name"], "Inline");
|
||||
assert_eq!(inline_read["rows"][0]["p.age"], 42);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue