GRAPH.RO_QUERY
Executes a given read only query against a specified graph.
Arguments: Graph name, Query, [timeout], [--compact], [version]
Returns: Result set for a read only query or an error if a write query was given.
| Optional argument | Description |
|---|---|
timeout |
Query-level timeout in milliseconds. See the configuration section. |
--compact |
Returns results in compact format. |
version |
Graph version number. When provided, the server rejects the query with a version mismatch error if the current graph version doesn’t match, allowing clients to invalidate cached schema mappings. |
graph.ro_query("MATCH (p:president)-[:born]->(:state {name:'Hawaii'}) RETURN p")
const result = await graph.roQuery("MATCH (p:president)-[:born]->(:state {name:'Hawaii'}) RETURN p");
console.log(result);
let result = graph.ro_query(r#"MATCH (p:president)-[:born]->(:state {name:'Hawaii'}) RETURN p"#).execute().await?;
println!("{:?}", result);
ResultSet result = graph.readOnlyQuery("MATCH (p:president)-[:born]->(:state {name:'Hawaii'}) RETURN p");
System.out.println(result);
GRAPH.RO_QUERY us_government "MATCH (p:president)-[:born]->(:state {name:'Hawaii'}) RETURN p"
Query-level timeouts can be set as described in the configuration section.
Frequently Asked Questions 4
What is the difference between GRAPH.QUERY and GRAPH.RO_QUERY?
GRAPH.RO_QUERY only executes read operations and will return an error if you attempt a write query (CREATE, SET, DELETE, MERGE with creation). GRAPH.QUERY supports both read and write operations.
Why should I use GRAPH.RO_QUERY instead of GRAPH.QUERY for reads?
GRAPH.RO_QUERY can be distributed to read replicas in a clustered setup, improving read scalability. It also provides a safety guarantee that data will not be accidentally modified.
What happens if I pass a write query to GRAPH.RO_QUERY?
The command will return an error indicating that write queries are not permitted. The graph data will remain unchanged.
Does GRAPH.RO_QUERY support the same optional parameters as GRAPH.QUERY?
Yes. GRAPH.RO_QUERY accepts the same optional parameters: timeout, --compact, and version.