Use parameter :param with label and/or key?


can I use param for label and/or type?

:param NodeLabel => 'person';
:param RelType => 'has_mail';

MATCH (n1:$NodeLabel)-[r:$RelType]->(n2) RETURN r, n1, n2;

in the browser I get an error :

Neo.ClientError.Statement.SyntaxError: Invalid input '$': expected whitespace or a label name (line 1, column 11 (offset: 10))
"MATCH (n1:$NodeLabel)-[r:$RelType]->(n2) RETURN r, n1, n2"

Is there are trick?
thanks rob

Hello @rob2 :slight_smile:

It is not possible to use a Label or a Type as a parameter in a MATCH clause.


Thanks - also not in a where statement i guess ... rob

Sorry, it's not possible in a MATCH clause but there is a workaround for WHERE clauses:

MATCH (n1)-[r]->(n2)
WHERE $NodeLabel IN LABELS(n1) AND type(r) = $RelType
RETURN r, n1, n2;


merci I will give it a try!