cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Draw graph after apoc.refactor.to call

Guys,

I have the following query:

MATCH
  (c:City {normalized_name: pLiveAddrCity}),
  (:TenantMAS {name: pTenantName})<-[:as_seen_by]-(la:LocalAgent {id: pAgentId})
MERGE
  (new_addr:Address {
    street_name:  pLiveAddrStreetName,
    number:       pLiveAddrNumber,
    neighborhood: pLiveAddrNeighborhood,
    cep:          pLiveAddrPostalCode
  })-[:belongs_to]->(c)
ON CREATE SET
  new_addr.latitude  = pLiveAddrLatitude,
  new_addr.longitude = pLiveAddrLongitude
WITH
  la,
  new_addr
OPTIONAL MATCH
  (la)-[rel_loc:is_located_at]->(:Address)
WITH
  la,
  new_addr,
  rel_loc
CALL apoc.do.when(
  rel_loc IS NULL,
  'MERGE (agent)-[:is_located_at]->(toNode)',
  'CALL apoc.refactor.to(rel_to_change, toNode) YIELD input, output, error RETURN error',
  {agent: la, rel_to_change: rel_loc, toNode: new_addr}
) YIELD value
RETURN
  new_addr

I am having a hard time trying to draw the graph after refactoring it connected with the parts that are were not refactored.

Is there a way of achieving this?

Please allow me a second question: where can I find documentation of what I should expect to find in the output of each APOC call? I know how to check the API with the apoc.help, but sometimes I don't know what to expect on a value or output return...

Thanks in advance,

3 REPLIES 3

The data types are listed in the "signature" column.
Many procedures are documented in more detail in the docs but usually apoc.help should be enough.

Not sure what you mean with your other question though. Can you explain it differently or show a picture?

Michael,
Sorry if I could not explain myself properly...

What I am trying to say is that I can verify the signature of the procedures with the apoc.help but it is not as trivial to "know" what the return is supposed to mean.

Say 'apoc.refactor.to`: what should I expected from the 'input' and 'output' fields?

Or, even worse apoc.do.when: what should VALUE mean as a return?

Just to relate to my initial question, I was trying to build a query that refactors my graph in a certain condition and to draw the newly refactored graph, but I could not achieve this with apoc.do.when and apoc.refactor.to because I could not understand what I should expected from the outputs (not the data type itself, but the content, the "meaning" of them).

Thank you for the constant help! 😉

We tried to keep the outputs of apoc procedures consistent.

input is the data that went into the procedure, i.e. the old relationship, output is the new data, i.e. new relationship.

value is usally a generic value (in many cases a stream of maps) in the case of apoc.when.do it's the query results of the inner query.