Set relationship types

The APOC library contains a procedure that can be used to change relationship types.

Procedure for changing relationship types

Qualified Name Type

apoc.refactor.setType(rel RELATIONSHIP, newType STRING) - changes the type of the given RELATIONSHIP.



The below example will further explain 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 the above query is run, it will result in the following graph: