apoc.refactor.cloneSubgraph doesn't preserve edge properties

I have found that the apoc.refactor.cloneSubgraph procedure does not preserve edge properties. Below is a simple recreate:

CREATE (:A)-[:R{id:"ID1"}]->(:B)

MATCH (n)-[r:R]->(oldB:B) 
WITH oldB, COLLECT(DISTINCT n) AS nodes 
CREATE (newB:B)

WITH oldB, newB, nodes 
MATCH (m)-[r]-(n) WHERE n IN nodes 

WITH oldB, newB, nodes, COLLECT(DISTINCT r) AS rels 
MATCH (s) WHERE NOT s:B 

WITH oldB, newB, nodes, rels, COLLECT(DISTINCT [s, s]) + [[oldB, newB]] AS standinNodes 
CALL apoc.refactor.cloneSubgraph(nodes, rels, {standinNodes:standinNodes}) 
YIELD input, output 
MATCH (old) WHERE ID(old) = input 
CREATE (output)-[r:importedFrom{created_on:datetime()}]->(old) 

RETURN output

I would expect that following this there would be a new "B" node with an edge to the existing A. That edge should clone the existing relationship between the original A and B. This happens, but the resulting edge does NOT contain the edge property "id" of "ID1". I would expect that all edge properties would be cloned along with the edge itself.

I'm seeing this on Neo4J v. 5.26.0, both interactive in Neo4J browser and via Java APIs

1 Like

I have confirmed the above behavior does NOT happen in 5.24.0 (5.24.2 APOC). It looks like cloneSubgraph was refactored in October and may have introduced this error. Please advise.

Hello @clark.adam! Thank you for reporting this bug, we are currently working on a fix to this issue and will have it corrected as soon as possible.