# apoc.refactor.cloneSubgraph doesn't preserve edge properties

**URL:** <https://community.neo4j.com/t/apoc-refactor-clonesubgraph-doesnt-preserve-edge-properties/72089>\
**Category:** Procedures & APOC\
**Tags:** apoc\
**Created:** [January 3, 2025, 4:19pm UTC](https://community.neo4j.com/t/apoc-refactor-clonesubgraph-doesnt-preserve-edge-properties/72089 "2025-01-03T16:19:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![clark.adam](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/clark.adam/32/33651_2.png) [@clark.adam](https://community.neo4j.com/u/clark.adam)\
**Post date:** [January 3, 2025, 4:19pm UTC](https://community.neo4j.com/t/apoc-refactor-clonesubgraph-doesnt-preserve-edge-properties/72089/1 "2025-01-03T16:19:53Z")

</div>

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)`

```auto
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

 ![image](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/c/6/c600cab7dab491c9605e343349fa2dd294040a44.png)

---

<div class="post-metadata">

**Author:** ![clark.adam](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/clark.adam/32/33651_2.png) [@clark.adam](https://community.neo4j.com/u/clark.adam)\
**Post date:** [January 3, 2025, 6:20pm UTC](https://community.neo4j.com/t/apoc-refactor-clonesubgraph-doesnt-preserve-edge-properties/72089/2 "2025-01-03T18:20:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![joel.bergstrand](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/joel.bergstrand/32/33196_2.png) [@joel.bergstrand](https://community.neo4j.com/u/joel.bergstrand)\
**Post date:** [January 7, 2025, 11:52am UTC](https://community.neo4j.com/t/apoc-refactor-clonesubgraph-doesnt-preserve-edge-properties/72089/3 "2025-01-07T11:52:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![barney](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/barney/32/34612_2.png) [@barney](https://community.neo4j.com/u/barney)\
**Post date:** [August 10, 2025, 4:30pm UTC](https://community.neo4j.com/t/apoc-refactor-clonesubgraph-doesnt-preserve-edge-properties/72089/4 "2025-08-10T16:30:31Z")

</div>

Hi Joel - can I ask whether this has been corrected?

Thanks, Barney

---

<div class="post-metadata">

**Author:** ![joel.bergstrand](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/joel.bergstrand/32/33196_2.png) [@joel.bergstrand](https://community.neo4j.com/u/joel.bergstrand)\
**Post date:** [September 16, 2025, 7:45am UTC](https://community.neo4j.com/t/apoc-refactor-clonesubgraph-doesnt-preserve-edge-properties/72089/5 "2025-09-16T07:45:01Z")

</div>

Hello @barney , sorry for the slow response.

The issue should be fixed on the latest 5.26 release of Neo4j and APOC.
