MERGE duplicate relationships

This CYPHER

MATCH(a) WHERE ID(a) =1 MATCH(b) WHERE ID(b) = 2 CREATE (n)-[r]->(l)

of course results in duplicate relationships when run twice

which CYPHER should run to merge the duplicate relationships into one, without affecting the nodes?

I'm not sure this works as your cypher is

MATCH(a) WHERE ID(a) =1 MATCH(b) WHERE ID(b) = 2 CREATE (n)-[r]->(l)

and your create references a node aliased as n and one aliased as l but I do not see where n or l defined.

Are you simply trying to create 1 relationship between node a and node b and if the above is run multiple times it should always result in only 1 relationship between a and b? Also, your relationship has no type. Is that what you want?

Maybe something similar to

MATCH(a) WHERE ID(a) =1 MATCH(b) WHERE ID(b) = 2 CREATE (a)-[:MY_RELATIONSHIP_TYPE]->(b)

I think this will help, but alas, the page doesn't have any examples, so you'll have to experiment:

This doc also doesn't explain the configure argument, but the config arguments are described with MergeNodes:

https://neo4j-contrib.github.io/neo4j-apoc-procedures/3.5/graph-refactoring/merge-nodes/