apoc.refactor.setType

Procedure

apoc.refactor.setType(rel Rel, newType String) - changes the type of the given relationship.

Signature

apoc.refactor.setType(relationship :: RELATIONSHIP?, newType :: STRING?) :: (input :: INTEGER?, output :: RELATIONSHIP?, error :: STRING?)

Input parameters

Name Type Default

relationship

RELATIONSHIP?

null

newType

STRING?

null

Output parameters

Name Type

input

INTEGER?

output

RELATIONSHIP?

error

STRING?

Usage Examples

The examples in this section are based on the following graph:

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 output:

Table 1. Results
input output

30

[:`NEW-TYPE`]

And the graph now looks like this:

apoc.refactor.setType2