8.5.6. Set Relationship Types

This section describes a procedure that can be used to change relationship types.

The available procedure is described in the table below:

call apoc.refactor.setType(rel, 'NEW-TYPE')

change relationship-type Example Usage

The example below will help us learn how to use this procedure.

The following creates a graph containing two nodes connected by a relationship: 

CREATE (f:Foo)-[rel:FOOBAR]->(b:Bar)


The following changes the relationship type from FOOBAR to NEW-TYPE

MATCH (f:Foo)-[rel:FOOBAR]->(b:Bar)
CALL apoc.refactor.setType(rel, 'NEW-TYPE')
YIELD input, output
RETURN input, output

If we execute this query, it will result in the following graph: