Memgraph

MemGQL supports two Memgraph connector modes:

  • memgraph — passthrough, forwards queries as-is (Cypher)
  • memgraph-gql — translates GQL to Cypher before execution

1. Start Memgraph

docker network create memgql-net
 
docker run -d --rm \
    --name memgraph-dev \
    --network memgql-net \
    -p 7687:7687 \
    memgraph/memgraph-mage:3.10.1 \
    --log-level=TRACE --also-log-to-stderr

2. Start MemGQL (GQL mode)

docker run --rm \
    --name memgql \
    --network memgql-net \
    --stop-timeout 2 \
    -p 7688:7688 \
    --env CONNECTOR_TYPE=memgraph-gql \
    --env MEMGRAPH_URI=memgraph-dev:7687 \
    --env BOLT_LISTEN_ADDR=0.0.0.0:7688 \
    memgraph/memgql:latest

For passthrough mode, use CONNECTOR_TYPE=memgraph instead.

3. Connect

mgconsole --port 7688

4. Seed data

INSERT
  (alice:Person {name: "Alice", age: 30}),
  (bob:Person {name: "Bob", age: 25}),
  (acme:Company {name: "Acme Corp"}),
  (alice)-[:KNOWS]->(bob),
  (alice)-[:WORKS_AT {role: "Engineer"}]->(acme);

5. Query

MATCH (p:Person) RETURN p.name, p.age;
MATCH (p:Person)-[:WORKS_AT]->(c:Company) RETURN p.name, c.name;
MATCH (a:Person)-[:KNOWS]->(b:Person) RETURN a.name, b.name;

For environment variables, see Reference.

Supported GQL features

GQL-specific syntax (INSERT, LOCAL_DATETIME, etc.) only works on memgraph-gql; the plain memgraph connector is Cypher passthrough.

FeatureMemgraph
MATCH / WHERE / RETURN
Pattern-level WHERE (MATCH (n WHERE …))
Multi-MATCH (cross-join)
OPTIONAL MATCH
WITH pipeline boundary
WITH DISTINCT / WITH … ORDER BY … LIMIT N
Chained WITH … WITH …
Whole-node WITH n carry-through
Typed edge (a)-[r:R]->(b)
Untyped edge ()-[]->(b)
UNION / UNION ALL / UNION DISTINCT
INTERSECT / EXCEPT
Quantified path (){m,n} — bounded
Quantified path (){m,} — unbounded
Shortest-path (ALL SHORTEST / SHORTEST k)
Path binding MATCH p = (…) RETURN p
Whole-node RETURN n
Map projections RETURN n {.a, .b}
IN list membership WHERE x IN [...]
STARTS WITH / ENDS WITH / CONTAINS
collect() aggregate
count, sum, avg, min, max
COUNT(DISTINCT …)
Arithmetic + - * / %
CASE WHEN … THEN … ELSE … END
COALESCE, NULLIF
Temporals (date, LOCAL_DATETIME, …)
INSERT (a {…}) RETURN a.x
DELETE / DETACH DELETE
SET / REMOVE (property update / delete)