Create dynamically relationship with var from unwinded list

Hello everybody!

I've this cypher query and I want to create relationship between 2 nodes dynamically:

UNWIND $list as l
MATCH (node:Category { code: l.code }), (target:Category { code: l.codeTarget })
MERGE (node)-[:l.predicate]->(target)

Is it possible to do something like this?

Thank's you !

check out apoc.create.relationship from apoc library. In plain cypher you cannot have dynamic relationship types.

2 Likes

APOC of course! Thank you very much!

1 Like