I am using some of the awesome apoc.refactor
procedures. I noticed that in the documentation there is no mention of the output variables names that one can use with YIELDS
.
I figured out that refactor.mergeNodes
outputs node
(as the new merged node), but I can't figure out what is the output name of refactor.to
or refactor.from
. I tried rel
and newRel
with no success. I am not a java programmer, but inspecting the code (especially RelationshipRefactorResult.java) I thought 'rel' was the one to go.
This is the query I am trying:
MATCH ()-[r]->(), (n)
WHERE id(r) = 16 AND id(n) = 4
CALL apoc.refactor.from(r,n) YIELD rel
RETURN rel
And this is the output message:
Unknown procedure output: `rel` (line 3, column 36 (offset: 96))
"RETURN rel"
Sorry that's a shortcoming of the current docs.
We want to automate / improve that.
You can see the output types if you CALL dbms.procedures()
CALL dbms.procedures() YIELD name, signature
WITH * WHERE name STARTS WITH 'apoc.refactor'
RETURN name, signature
The signature is always name :: TYPE
e.g. in your case:
apoc.refactor.to(relationship :: RELATIONSHIP?, newNode :: NODE?)
:: (input :: INTEGER?, output :: RELATIONSHIP?, error :: STRING?)
Parameters:
relationship
, Type: RelationshipnewNode
, Type: NodeOutput Columns:
input
, Type: Integer output
, Type Relationshiperror
, Type: StringBuilding on the answer of Michael, here is a little tool. Just a query that builds tidy documentation for these. :) Maybe it can be adapted to work for others procedures too.
//EXPOSED YIELD PARAMETERS OUTPUT FROM apoc.periodic...
CALL dbms.procedures() YIELD name, signature
WITH * WHERE name STARTS WITH 'apoc.periodic'
RETURN name AS procedure, 'YIELD',
tail(
apoc.text.split(
toString(apoc.text.split(signature, '\\)')[1])
, '[^a-z]+[^a-zA-Z]*[^a-z]')
) AS exposed_parameters
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With