GRAPH.QUERY

Executes the given query against a specified graph.

Arguments: Graph name, Query, [timeout], [--compact], [version]

Returns: Result set

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.

Queries and Parameterized Queries

The execution plans of queries, both regular and parameterized, are cached (up to CACHE_SIZE unique queries are cached). Therefore, it is recommended to use parameterized queries when executing many queries with the same pattern but different constants.

Query-level timeouts can be set as described in the configuration section.

Command structure

GRAPH.QUERY graph_name "query" [timeout value] [--compact] [version value]

example:


graph.query("MATCH (p:president)-[:born]->(:state {name:'Hawaii'}) RETURN p")

const result = await graph.query("MATCH (p:president)-[:born]->(:state {name:'Hawaii'}) RETURN p");
console.log(result);

let result = graph.query(r#"MATCH (p:president)-[:born]->(:state {name:'Hawaii'}) RETURN p"#).execute().await?;
println!("{:?}", result);

ResultSet result = graph.query("MATCH (p:president)-[:born]->(:state {name:'Hawaii'}) RETURN p");
System.out.println(result);

GRAPH.QUERY us_government "MATCH (p:president)-[:born]->(:state {name:'Hawaii'}) RETURN p"

Parameterized query structure:

GRAPH.QUERY graph_name "CYPHER param=val [param=val ...] query"

example:


graph.query("MATCH (p:president)-[:born]->(:state {name:$state_name}) RETURN p", {'state_name': 'Hawaii'})

const result = await graph.query(
  "MATCH (p:president)-[:born]->(:state {name:$state_name}) RETURN p",
  { params: { state_name: "Hawaii" } }
);
console.log(result);

let params = std::collections::HashMap::from([
    ("state_name", "Hawaii")
]);
let result = graph.query_with_params(
    r#"MATCH (p:president)-[:born]->(:state {name:$state_name}) RETURN p"#,
    &params
).execute().await?;
println!("{:?}", result);

Map<String, Object> params = new HashMap<>();
params.put("state_name", "Hawaii");
ResultSet result = graph.query(
  "MATCH (p:president)-[:born]->(:state {name:$state_name}) RETURN p",
  params
);
System.out.println(result);

GRAPH.QUERY us_government "CYPHER state_name='Hawaii' MATCH (p:president)-[:born]->(:state {name:$state_name}) RETURN p"

Query language

The syntax is based on Cypher. Most of the language is supported. See Cypher documentation.