Skip to content

Dynamic node labels within list #1156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions pages/querying/expressions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ MATCH (n:$label)
RETURN n;
```

This syntax supports parameters of type `String` and `List[String]`, allowing a
node to have one or multiple labels assigned.

Using parameters as property maps is partially supported, it isn't supported in `MATCH` nor `MERGE`
clause. For example, the following query is illegal:

Expand Down Expand Up @@ -109,6 +112,26 @@ session.run('CREATE (alice:Person {name: $0, age: $1})',
To use parameters with some other driver, please consult the appropriate
documentation.

## Dynamic node labels creation

Starting from version 3.1, Memgraph allows node labels to be created using
expressions of type `String` or `List[String]`.

For example, the following query will create a node with the label `Foo`:

```
WITH {label: "Foo"} as var
CREATE (:var.label);
```

while the following query will result in the creation of node labels `Foo` and `Bar`.

```
WITH {labels: ["Foo", "Bar"]} as var
CREATE (:var.labels);
```


## CASE

Conditional expressions can be expressed in the Cypher language with the `CASE`
Expand Down