Supported Cypher

This page maps the library’s surface to the groups and terms of the Cypher 25 cheat sheet. Everything listed under a supported heading can be built and rendered. Constraints that apply are stated where the feature appears. The two lists at the end carry what this release does not cover, split into what is not yet implemented and what is not planned. Neither list is exhaustive, so a form this page does not name may still be missing. Every Not yet entry links to its issue, and a thumbs-up reaction there is a vote for it.

Release floors are a separate matter: a supported feature can still require a newer declared release. Choose a target explains how the declaration selects syntax.

Read

MATCH

node() builds a node pattern with an optional primary label or label expression, an optional variable, an optional property map and an optional inline element predicate. Without a label it writes (p) or (). node(name="p") renders the bare reference to a node the clause already holds.

from cypher_dsl import Configuration, Renderer, match, node

movie = node("Movie", name="m")
statement = (
    match(movie)
    .match(node(name="m").relationship_from(node(), "DIRECTED"))
    .returning(movie["title"])
)
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH (m:Movie)
MATCH (m)<-[:DIRECTED]-()
RETURN m.title

Relationship patterns take one type or a label expression and a direction. A chain extends from its current endpoint, so a multi-relationship path stays one pattern. path_phrase builds a path pattern and carries its variable and selector, so see the path variable and path selectors. Every selector but ALL must be its MATCH clause’s only pattern.

shortest(param("k")) renders SHORTEST $k. See path selectors for the other forms.

from cypher_dsl import (
    Configuration,
    Quantifier,
    Renderer,
    match,
    name,
    node,
    param,
    path_phrase,
    shortest,
)

knows = node("Person", name="a").relationship_to(
    node("Person"), "KNOWS", quantifier=Quantifier.one_or_more()
)
statement = match(
    path_phrase(knows, variable=name("p"), selector=shortest(param("k")))
).returning(name("p"))

renderer = Renderer.get(
    Configuration(server_version="2025.06", pretty_print=True)
)
print(renderer.render(statement).cypher)
CYPHER 25
MATCH p = SHORTEST $k (a:Person)-[:KNOWS]->+(:Person) RETURN p

optional_match writes OPTIONAL MATCH for the same patterns and keeps the incoming rows when nothing matches. See optional match.

UNWIND

unwind turns a collection into one row per element. The second argument is a name() and the source is any expression, so a Python list is accepted as it stands. It may start a statement or follow one. WHERE cannot attach to it, so a filter on its rows goes through a WITH: see Filter an UNWIND through WITH.

from cypher_dsl import Configuration, Renderer, match, name, node, unwind

person = node("Person", name="p")
statement = (
    match(person)
    .unwind(person["tags"], name("tag"))
    .returning(person["uid"], name("tag"))
)
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH (p:Person)
UNWIND p.tags AS tag
RETURN p.uid, tag

WHERE

Conditions combine comparisons with & (AND), | (OR), ^ (XOR) and ~ (NOT), plus the membership, string and regular-expression predicates. See condition builders for each builder in turn.

from cypher_dsl import (
    Configuration,
    Renderer,
    match,
    node,
    param,
    starts_with,
)

person = node("Person", name="p")
statement = (
    match(person)
    .where(
        (person["age"] < param("max_age"))
        & starts_with(person["uid"], "A")
    )
    .returning(person["uid"])
)
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH (p:Person) WHERE p.age < $max_age AND p.uid STARTS WITH 'A'
RETURN p.uid

A node or relationship pattern also takes an inline element predicate with predicate=. It is applied while matching, before a path selector chooses paths, so a selector can return different rows than the same condition in a clause WHERE. See test an element while the pattern matches.

from cypher_dsl import Configuration, Renderer, match, name, node

person = node("Person", name="p", predicate=name("p")["enabled"])
statement = match(person).returning(person["display_name"])
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH (p:Person WHERE p.enabled) RETURN p.display_name

has_label tests a node’s labels or a relationship’s type against a label expression. The colon form with static terms works on every supported release. A dynamic term is Cypher 25 only from 2025.07, as label expression predicates explains.

is_labeled and is_not_labeled render the IS [NOT] LABELED form, which Neo4j 2026.04 introduced for Cypher 25, so the statement selects the CYPHER 25 prefix under Language.AUTO. See the label expression predicate.

is_type and is_not_type render the IS [NOT] :: type predicate. The type name is one of the server’s simple type names or their synonyms, such as INTEGER, PROPERTY VALUE or LOCAL DATETIME, rendered as written and never quoted. not_null=True appends NOT NULL, which makes the tested type non-nullable: it excludes null, so a missing value fails the positive form. See type predicates for the forms the builders refuse.

Path pattern expressions

path_pattern turns a relationship chain into a boolean: it is true when the chain matches at least once. It is a predicate, so &, |, ^ and ~ combine it with other conditions. Every named node and relationship in the chain must reference a name an earlier clause binds. The expression declares none of its own. The chain renders as written, including every label on a restated node, because Neo4j reads a restated label as a predicate.

from cypher_dsl import (
    Configuration,
    Renderer,
    lit,
    match,
    node,
    path_pattern,
)

person = node("Person", name="p")
works_for = person.relationship_to(
    node("Person", properties={"uid": lit("p1")}), "WORKS_FOR"
)
statement = (
    match(person)
    .where(path_pattern(works_for))
    .returning(person["uid"])
)
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH (p:Person) WHERE (p:Person)-[:WORKS_FOR]->(:Person {uid: 'p1'})
RETURN p.uid

A projection item is not a boolean position: project ~path_pattern(...) instead. The chain holds no quantifier: build a quantified relationship or quantified path pattern with match and wrap it in exists. An inline element predicate also belongs in a MATCH clause, so path_pattern refuses one. Use exists with a MATCH body. A pattern that binds its own names or needs clauses of its own needs the exists subquery form too. The scope rules are documented with the read clauses: see path pattern expressions.

RETURN

Projections take expressions, aliases, DISTINCT, ORDER BY, SKIP and LIMIT. desc and asc write the sort direction. A bare ordering expression sorts ascending without the token.

from cypher_dsl import Configuration, Renderer, match, node

movie = node("Movie", name="m")
statement = (
    match(movie)
    .returning(movie["title"])
    .distinct()
    .order_by(movie["title"])
    .skip(10)
    .limit(5)
)
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH (m:Movie)
RETURN DISTINCT m.title ORDER BY m.title SKIP 10 LIMIT 5

WITH

WITH ends one query part and starts the next. Only the names it projects are available afterwards. A structured projection item needs an alias.

from cypher_dsl import Configuration, Renderer, desc, match, node

person = node("Person", name="p")
statement = (
    match(person)
    .with_(person)
    .order_by(desc(person["rating"]))
    .limit(1)
    .returning(person["display_name"])
)
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH (p:Person)
WITH p ORDER BY p.rating DESC LIMIT 1
RETURN p.display_name

GROUP BY

group_by names the grouping keys explicitly, and group_by_all makes every non-aggregating projection item a key. Both are Cypher 25 only, added in Neo4j 2026.07, so Language.AUTO selects the CYPHER 25 prefix on each statement it renders. See Group explicitly for the key rules and the two forms:

from cypher_dsl import Configuration, Renderer, count, match, node

movie = node("Movie", name="m")
keyed = (
    match(movie)
    .returning(movie["genre"].alias("genre"), count(movie).alias("films"))
    .group_by("genre")
    .order_by("genre")
)
renderer = Renderer.get(
    Configuration(server_version="2026.10", pretty_print=True)
)
print(renderer.render(keyed).cypher)
CYPHER 25
MATCH (m:Movie) RETURN m.genre AS genre, count(m) AS films GROUP BY genre ORDER BY genre

Write

CREATE

CREATE writes node patterns and relationship patterns. A write relationship renders the type and direction it carries: a plain type or one $() term, or no type at all, and an undirected form when the factory gives one. The property map is explicit entries, a map literal or a whole-map parameter. A map expression or a variable in that slot needs SET instead, because the grammar does not accept it.

from cypher_dsl import Configuration, Renderer, create, node, param

statement = create(
    node("Person", name="p", properties={"email": param("email")})
)
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
CREATE (p:Person {email: $email})

MERGE

MERGE takes one identity pattern with explicit properties and at most one ON CREATE and one ON MATCH action.

from cypher_dsl import Configuration, Renderer, assign, merge, node, param

person = node("Person", name="p", properties={"email": param("email")})
statement = (
    merge(person).on_match(assign(person["seen_at"], param("now")))
)
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MERGE (p:Person {email: $email})
    ON MATCH SET p.seen_at = $now

SET

assign replaces a value, update_properties patches a map, and set_labels adds labels. A dynamic label comes from dynamic_label, which writes the colon form. See dynamic labels for the read and write forms.

from cypher_dsl import (
    Configuration,
    Renderer,
    assign,
    match,
    node,
    set_labels,
)

person = node("Person", name="p")
statement = (
    match(person)
    .set_(assign(person["age"], 36), set_labels(person, "Employee"))
    .returning(person["display_name"])
)
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH (p:Person) SET p.age = 36, p:Employee
RETURN p.display_name

REMOVE

REMOVE takes property references and label updates.

from cypher_dsl import Configuration, Renderer, match, node, set_labels

person = node("Person", name="p")
statement = (
    match(person)
    .remove(person["age"], set_labels(person, "Employee"))
    .returning(person["display_name"])
)
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH (p:Person) REMOVE p.age, p:Employee
RETURN p.display_name

DELETE

delete removes named elements. detach_delete also removes their relationships.

from cypher_dsl import Configuration, Renderer, match, node

person = node("Person", name="p")
statement = match(person).detach_delete(person)
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH (p:Person) DETACH DELETE p

Patterns

Node patterns

node() takes an optional primary label or label expression, an optional variable and an optional property map. with_labels extends a pattern with label names and $() terms.

from cypher_dsl import Configuration, Renderer, match, node

person = node("Person", name="p")
statement = (
    match(person.with_labels("Employee"))
    .returning(person["display_name"])
)
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH (p:Person:Employee) RETURN p.display_name

Label expressions

label() terms and the dynamic label factories combine with & (both), | (either) and ~ (not, rendered as !), plus ANY_LABEL for the % wildcard. The same grammar serves node labels and relationship types.

from cypher_dsl import Configuration, Renderer, label, match, node

pattern = node(label("Movie") | label("Person"), name="n")
statement = match(pattern).returning(pattern["title"])
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH (n:Movie|Person) RETURN n.title

A label expression states what to match. It also renders as written in CREATE and MERGE, and Neo4j decides whether the write accepts it. See Write data for the label and type forms.

Dynamic labels decide the label at run time. dynamic_label writes $(...), while label_any and label_all write the $any(...) and $all(...) forms. The two list forms are read forms, and a read pattern combines a dynamic label with & or |. See dynamic labels. Relationship patterns ~~~~~~~~~~~~~~~~~~~~~

A relationship takes one type or a union of types. Adjacent relationships in a chain meet at the same node pattern object, so a chain cannot describe two different nodes under one name.

from cypher_dsl import Configuration, Renderer, label, match, node

credits = node("Person", name="p").relationship_to(
    node("Movie"), label("ACTED_IN") | label("DIRECTED"), name="r"
)
statement = match(credits).returning(credits["character"])
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH (p:Person)-[r:ACTED_IN|DIRECTED]->(:Movie)
RETURN r.character

Quantified path patterns

quantified repeats a relationship chain a number of times, and the optional where predicate is evaluated for each repetition:

from cypher_dsl import (
    Configuration,
    Quantifier,
    Renderer,
    match,
    name,
    node,
)

source = node("Station", name="s")
target = node("Station", name="t")
route = source.relationship_to(target, "LINK").quantified(
    Quantifier.between(1, 3),
    where=source["departs"] < target["departs"],
)
statement = match(route).returning(name("s"), name("t"))
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH ((s:Station)-[:LINK]->(t:Station) WHERE s.departs < t.departs){1,3}
RETURN s, t

Outside the parentheses every inner name is a group variable, a list of the nodes or relationships matched in each repetition. A quantified relationship takes the same quantifier on relationship_to, relationship_from or relationship_with, and path_phrase concatenates simple and quantified segments into one path pattern. The quantifier forms, the scope and write rules, and the layout of a long pattern are under quantified relationships, quantified path patterns and path phrases.

Composed queries

UNION

union combines whole statements and returns a draft. all=True renders UNION ALL. Every branch must end in RETURN or none may, and an empty branch is rejected when union() receives it. The library does not compare the branches, so column agreement across them is Neo4j’s check.

from cypher_dsl import Configuration, Renderer, match, node, union

person = node("Person", name="n")
movie = node("Movie", name="n")
statement = union(
    match(person).returning(person),
    match(movie).returning(movie),
)
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH (n:Person) RETURN n
UNION
MATCH (n:Movie) RETURN n

Subqueries and procedures

CALL

A CALL subquery is written once for every outer row. The variable scope clause always renders, and imports or import_all pass outer names in. The body is a statement builder, a union draft or a finalised statement. A body must stay a builder or draft when standalone validation cannot resolve an import it reads, because building it alone would find the name unbound.

from cypher_dsl import Configuration, Renderer, match, name, node

person = node("Person", name="p")
movie = node("Movie", name="m")
acted = node(name="p").relationship_to(movie, "ACTED_IN")
body = match(acted).returning(
    movie["title"].alias("title")
)
statement = match(person).call(
    body, imports=("p",)
).returning(name("title"))
renderer = Renderer.get(
    Configuration(server_version="5.26", pretty_print=True)
)
print(renderer.render(statement).cypher)
MATCH (p:Person)
CALL (p) {
  MATCH (p)-[:ACTED_IN]->(m:Movie) RETURN m.title AS title
}
RETURN title

optional_call renders the optional form of the same call.

CALL ... IN TRANSACTIONS

InTransactions appends the transaction modifier. InTransactions() writes the bare keyword, rows writes OF ... ROWS, concurrency writes the concurrent form, disjoint_by adds the batch scheduling hint, and on_error with report_status adds the failure policy and the status binding. See Write in batches for the forms and the floors.

from cypher_dsl import (
    Configuration,
    InTransactions,
    Renderer,
    create,
    fn,
    name,
    node,
    unwind,
)

body = create(node("Clone", properties={"uid": name("item")}))
statement = (
    unwind(fn("range", 1, 1_000), name("item"))
    .call(
        body,
        imports=("item",),
        in_transactions=InTransactions(rows=100, concurrency=4),
    )
    .returning(name("item"))
)
renderer = Renderer.get(
    Configuration(server_version="5.26", pretty_print=True)
)
print(renderer.render(statement).cypher)
UNWIND range(1, 1000) AS item
CALL (item) {
  CREATE (:Clone {uid: item})
} IN 4 CONCURRENT TRANSACTIONS OF 100 ROWS
RETURN item

Procedures

call_procedure names the procedure in one dot-qualified string. yielding keeps the named output columns. optional_call_procedure renders the optional form, which keeps a row the procedure has no output for. See Call procedures for both.

from cypher_dsl import Configuration, Renderer, call_procedure, name, param

statement = (
    call_procedure("dbms.checkConfigValue", param("setting"), "true")
    .yielding("valid")
    .returning(name("valid"))
)
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
CALL dbms.checkConfigValue($setting, 'true') YIELD valid RETURN valid

EXISTS

exists builds an existential subquery expression. It is a predicate, so it filters in WHERE, projects in RETURN and combines with &, |, ^ and ~. The body sees the enclosing scope without a scope clause. The library does not reject a writing body. Cypher decides which bodies EXISTS accepts, and the server rejects the rest.

from cypher_dsl import (
    Configuration,
    Renderer,
    exists,
    match,
    node,
    param,
)

person = node("Person", name="p")
dog = node("Dog", name="d")
walked = match(node(name="p").relationship_to(dog, "HAS_DOG")).where(
    dog["name"] == param("dog_name")
)
statement = match(person).where(exists(walked)).returning(person["name"])
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH (p:Person)
  WHERE EXISTS {
    MATCH (p)-[:HAS_DOG]->(d:Dog)
      WHERE d.`name` = $dog_name
  }
RETURN p.`name`

The scope rules, the pattern-element form and the limits are in Test whether a subquery matches.

COUNT and COLLECT

count_subquery and collect_subquery build the COUNT { ... } and COLLECT { ... } subquery expressions. Both are value expressions that read the enclosing scope without a scope clause. COUNT counts the body’s rows and its body may end without a RETURN. COLLECT builds a list and every branch must end in a RETURN with exactly one expression. RETURN * is one expression and passes the library’s syntactic check, so Neo4j still decides that the body yields one column. See Count the rows of a subquery and Collect a subquery into a list.

from cypher_dsl import (
    Configuration,
    Renderer,
    count_subquery,
    lit,
    match,
    node,
)

person = node("Person", name="p")
walked = match(node(name="p").relationship_to(node("Dog"), "HAS_DOG"))
statement = (
    match(person)
    .where(count_subquery(walked) > lit(1))
    .returning(person["name"])
)
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH (p:Person)
  WHERE COUNT {
    MATCH (p)-[:HAS_DOG]->(:Dog)
  } > 1
RETURN p.`name`
from cypher_dsl import (
    Configuration,
    Renderer,
    collect_subquery,
    in_,
    lit,
    match,
    node,
)

person = node("Person", name="p")
dog = node("Dog", name="d")
dogs = match(node(name="p").relationship_to(dog, "HAS_DOG")).returning(dog["name"])
statement = (
    match(person)
    .where(in_(lit("Ozzy"), collect_subquery(dogs)))
    .returning(person["name"])
)
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH (p:Person)
  WHERE 'Ozzy' IN COLLECT {
    MATCH (p)-[:HAS_DOG]->(d:Dog) RETURN d.`name`
  }
RETURN p.`name`

Expressions

Comparisons, boolean operators, arithmetic, IN, string predicates, the =~ match, || concatenation, literals, parameters, lists, maps and subscripts are accepted wherever the grammar takes a value. A property read can use a computed key for a dynamic property name:

from cypher_dsl import Configuration, Renderer, match, node, param

person = node("Person", name="p")
statement = match(person).where(person[param("prop")] > 40).returning(
    person["display_name"]
)
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH (p:Person) WHERE p[$prop] > 40 RETURN p.display_name

concat builds the || concatenation, which joins only strings:

from cypher_dsl import Configuration, Renderer, concat, match, node

person = node("Person", name="p")
statement = match(person).returning(
    concat(concat(person["first_name"], " "), person["last_name"])
)
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH (p:Person) RETURN p.first_name || ' ' || p.last_name

A boolean read from a parameter needs condition(). A bare and, or or not cannot be overloaded, so conditions combine with &, |, ^ and ~.

list_comprehension builds [x IN list WHERE p | e], and reduce folds a list into one value. Both bind their names inside the expression, so the element variable and the accumulator stay invisible to the clauses around them. See list comprehensions and folds for both builders:

from cypher_dsl import (
    Configuration,
    Renderer,
    list_comprehension,
    match,
    name,
    node,
)

person = node("Person", name="p")
statement = (
    match(person)
    .returning(
        list_comprehension(
            name("x"),
            person["roles"],
            where=name("x")["kind"] == "lead",
            result=name("x")["title"],
        )
    )
)
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH (p:Person) RETURN [x IN p.`roles` WHERE x.kind = 'lead' | x.title]

The WHERE part and the mapping expression are optional, so a comprehension with neither renders [x IN coll] and does not filter anything. reduce needs both bindings and the combining expression:

from cypher_dsl import (
    Configuration,
    Renderer,
    assign,
    match,
    name,
    node,
    reduce,
)

person = node("Person", name="p")
statement = (
    match(person)
    .set_(
        assign(
            person["score"],
            reduce(
                name("total"), 0,
                name("n"), person["ratings"], name("total") + name("n"),
            ),
        )
    )
)
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH (p:Person) SET p.`score` = reduce(total = 0, n IN p.ratings | total + n)

all_, any_, none and single build quantified list predicates, which test the elements of a list against a condition. See quantified list predicates for how the four differ and why two of the names carry a trailing underscore:

from cypher_dsl import (
    Configuration,
    Renderer,
    all_,
    any_,
    match,
    name,
    node,
    none,
    single,
)

person = node("Person", name="p")
ratings = person["ratings"]
rating = name("rating")
renderer = Renderer.get(Configuration(server_version="5.26"))

every_high = match(person).returning(all_(rating, ratings, rating >= 4))
print(renderer.render(every_high).cypher)

some_high = match(person).returning(any_(rating, ratings, rating >= 4))
print(renderer.render(some_high).cypher)

no_high = match(person).returning(none(rating, ratings, rating >= 4))
print(renderer.render(no_high).cypher)

one_high = match(person).returning(single(rating, ratings, rating >= 4))
print(renderer.render(one_high).cypher)
MATCH (p:Person) RETURN all(rating IN p.ratings WHERE rating >= 4)
MATCH (p:Person) RETURN any(rating IN p.ratings WHERE rating >= 4)
MATCH (p:Person) RETURN none(rating IN p.ratings WHERE rating >= 4)
MATCH (p:Person) RETURN single(rating IN p.ratings WHERE rating >= 4)

map_projection reads a variable and returns a map of selected properties, literal entries or all properties. See map projection for entries and all properties. Properties are names and are quoted by the identifier rules, entry values are expressions, and all_properties=True adds the .* selector before the others:

from cypher_dsl import Configuration, Renderer, map_projection, match, node

person = node("Person", name="p")
statement = match(person).returning(
    map_projection(
        person,
        properties=("uid", "name"),
        entries={"total": person["a"] + person["b"] + person["c"]},
    )
)
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH (p:Person)
RETURN p{.uid, .`name`, total: p.a + p.b + p.c}

all_properties=True includes every property of the variable:

from cypher_dsl import Configuration, Renderer, map_projection, match, node

person = node("Person", name="p")
statement = match(person).returning(
    map_projection(person, properties=("uid",), all_properties=True)
)
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH (p:Person) RETURN p{.*, .uid}

CASE

case and case_when build the searched conditional form CASE WHEN condition THEN value ... ELSE value END. The branches are tested in order, the first true condition selects its value, and else_ supplies the fallback. Without it, the expression has no ELSE part. Every branch and the fallback are expressions read in the enclosing scope. Only the searched form is built: the simple form CASE <expr> WHEN ... is refused at construction, and raw() builds it. See conditional expressions:

from cypher_dsl import (
    Configuration,
    Renderer,
    case,
    case_when,
    match,
    node,
)

person = node("Person", name="p")
statement = match(person).returning(
    case(
        case_when(person["age"] < 18, "minor"),
        else_="adult",
    )
)
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH (p:Person)
RETURN CASE WHEN p.age < 18 THEN 'minor' ELSE 'adult' END

Functions

fn() builds any call by name, including dot-qualified names. These functions have their own builders:

Builder

Renders

count(value)

count(value)

count(value, distinct=True)

count(DISTINCT value)

count(asterisk())

count(*)

element_id(value)

elementId(value)

length(path)

length(path)

nodes(path)

nodes(path)

relationships(path)

relationships(path)

See Call functions for the argument rules:

from cypher_dsl import (
    Configuration,
    Renderer,
    count,
    element_id,
    match,
    node,
)

person = node("Person", name="p")
statement = match(person).returning(
    count(person).alias("people"), element_id(person).alias("identifier")
)
renderer = Renderer.get(Configuration(server_version="5.26"))
print(renderer.render(statement).cypher)
MATCH (p:Person) RETURN count(p) AS people, elementId(p) AS identifier

Targets

The rendered text depends on the declared release and language. Choose a target explains the floors, the CYPHER 5 and CYPHER 25 prefixes, identifier escaping and the multi-line layout behind pretty_print. A supported feature that needs a newer release is rejected at render time when the declaration is too old.

What Neo4j checks

The library holds no catalogue, no data and no server connection, so these checks are left to the server:

  • Endpoint legality when a write pattern names an already bound node. The reference occurrence sends only the name, with no labels and no property map for the server to compare. Whether the statement is legal is Neo4j’s check.

  • Column agreement across UNION branches.

  • The output columns a procedure produces, and whether a YIELD item names one.

  • Whether a grouping key and the projected aggregates form a legal GROUP BY.

  • Which query bodies EXISTS, COUNT and COLLECT accept, including a writing body.

  • Query parts: in Cypher 5, a WITH between a write clause and a following reading clause. The WITH manual states that Cypher 25 no longer requires it.

  • Whether nodes(), relationships() and length() receive a path.

  • Whether a group variable is used as a write endpoint or an update target, and whether a write endpoint is legal at all.

  • Whether a pattern makes sense for the graph: label existence, node versus path, and property types.

Running the rendered text through EXPLAIN on a server you own answers the parse and plan questions.

Not yet

The entries below are the known missing constructs. There might be more. The order is not the priority. Use the linked github issues to vote.

  • SEARCH n IN (VECTOR INDEX idx FOR $v) SCORE AS s, and the FULLTEXT variation: vector and full-text search. Tracked in #1.

  • FOREACH (x IN list | SET ...): an updating loop. Tracked in #2.

  • CASE <expr> WHEN ... THEN ... ELSE ... END: the simple CASE form. The searched form is built. Tracked in #3.

  • INTEGER | FLOAT: a closed union of type names in a type predicate. The simple type names are built. Tracked in #4.

  • LIST<...>, VECTOR<...>, INTEGER LIST and INTEGER ARRAY: parametrised and postfix types in a type predicate. Tracked in #5.

  • Match modes and path modes: DIFFERENT RELATIONSHIPS, REPEATABLE ELEMENTS, WALK, TRAIL and ACYCLIC, the grammar that surrounds a path pattern beside the path selectors. They are Cypher 25 only. Tracked in #6.

  • USING INDEX, INDEX SEEK, SCAN, JOIN: planner hints. Tracked in #7.

Not planned

Below are language constructs I currently do not plan to implement. Either because I deem they have no place in a DSL or because they are only in the language to fulfill GQL requirements but have identical counterparts in Cypher already.

  • LOAD CSV: a loading tool for demos, not query construction. The builders do not produce it.

  • EXPLAIN and PROFILE: developer tooling.

  • -[:R*1..3]->: the legacy variable-length syntax, superseded by quantified path patterns.

  • shortestPath() and allShortestPaths(): the functions the path selectors replace. SHORTEST k, ALL SHORTEST and ANY k express them in MATCH, where a path variable holds the result, and a shortest path projected per row is a CALL subquery that returns it.

  • ANY: a synonym of ANY 1. Use any_paths(), whose count says what the bare word leaves implicit.

  • ANY SHORTEST: a synonym of SHORTEST 1. Use shortest(1).

  • PATH and PATHS: filler words after a selector, such as ALL PATHS for ALL. The built selectors leave them out.

  • CREATE INDEX, CREATE CONSTRAINT and graph types: schema management, not query construction.

  • SHOW INDEXES and the other SHOW commands: administrative and introspection commands. Procedure calls cover the introspection the builders support.

  • USE database: the executing session selects the database. USE serves shells and the Browser, and a builder cannot validate a graph it never connects to.

  • OFFSET: a synonym of SKIP. Use skip().

  • INSERT: a synonym of CREATE that requires & between labels. Use create().

  • IS TYPED: the long spelling of IS ::. Use is_type().

  • UNION DISTINCT and brace-grouped unions: explicit spellings of UNION, which already removes duplicates.

  • FILTER and LET: clauses for what WHERE and WITH ... AS already do.

  • GROUP BY (): the empty grouping. An aggregate-only projection already groups over every row, so the form states what the projection already means.

  • FOR x IN [1, 2, 3]: a row producer that unwind() already covers.

  • FINISH: a query that returns nothing already ends at its write clause.

  • NEXT and standalone WHEN ... THEN ... ELSE ...: conditional and sequential forms that a CALL subquery with a filter and a WITH boundary already cover.