I am trying to change the rel type of a relationship as outlined below and getting the following error:
Neo.ClientError.Statement.SyntaxError: Procedure call inside a query does not support naming results implicitly (name explicitly using `YIELD` instead) (line 4, column 22 (offset: 224))
" call apoc.refactor.setType(r, 'OWNED')"
If adding YIELD is the answer I am not sure what to YIELD ??
MATCH (user:Owner {email: "xyz@mymail.com"})-[r:OWNS]->(v:Vehicles {name:"Chevy"})
WHERE r.model = "Silverado" OR NOT EXISTS(r.model)
WITH r,user,v
call apoc.refactor.setType(r, 'OWNED')
YIELD ?????
RETURN user,r,v
You can use the apoc.help procedure to see the signature of APOC functions. For example, the result of this statement:
CALL apoc.help("apoc.refactor.setType")
is:
╒═══════════╤══════════════════╤══════════════════╤══════════════════╤═══════╤════════╕
│"type" │"name" │"text" │"signature" │"roles"│"writes"│
╞═══════════╪══════════════════╪══════════════════╪══════════════════╪═══════╪════════╡
│"procedure"│"apoc.refactor.set│"apoc.refactor.set│"apoc.refactor.set│null │null │
│ │Type" │Type(rel, 'NEW-TYP│Type(relationship │ │ │
│ │ │E') change relatio│:: RELATIONSHIP?, │ │ │
│ │ │nship-type" │newType :: STRING?│ │ │
│ │ │ │) :: (input :: INT│ │ │
│ │ │ │EGER?, output :: R│ │ │
│ │ │ │ELATIONSHIP?, erro│ │ │
│ │ │ │r :: STRING?)" │ │ │
└───────────┴──────────────────┴──────────────────┴──────────────────┴───────┴────────┘
So, apoc.refactor.setType
has these yieldable variables: input
, output
and error
.
This query should work for you:
MATCH (user:Owner {email: "xyz@mymail.com"})-[r:OWNS]->(v:Vehicles {name:"Chevy"})
WHERE r.model = "Silverado" OR NOT EXISTS(r.model)
CALL apoc.refactor.setType(r, 'OWNED') YIELD output
RETURN user, output AS r, v