neo4j query conversion to use in function


Author: gorrch

Originally Sourced from: https://stackoverflow.com/questions/66076600/neo4j-query-conversion-to-use-in-function

I have such query, which normally accepts one argument in {} brackets.

MATCH (pr:Person)-[:person_successor]->(next:Person)
  WHERE (:Queue {name: 'A'}) -[:queue_person]-> (pr)
  RETURN pr.name, next.name

I want to pass as Queue name several possible arguments instead of one, e.g. {name: 'A' or name: 'B'}. So I want to have people and their successors from many queues. Queues are also connected one to another. But such query is not possible and throws exception:

MATCH (pr:Person)-[:person_successor]->(next:Person)
  WHERE (:Queue {name: 'A' or name: 'B'}) -[:queue_person]-> (pr)
  RETURN pr.name, next.name

Instead of above, works sth like this:

MATCH (q:Queue)-[:queue_person]->(pr:Person)-[:person_successor]->(:next:Person)
  WHERE q.name in ['A','B']
  RETURN pr.name, next.name

But I would like to use (pr:Person)-[:person_successor]->(next:Person) instead of (q:Queue)-[:queue_person]->(pr:Person)-[:person_successor]->(:next:Person) because somehow it spoil person order so as a result I do not have:

A B

B C

C D

D E ...

It is disturbed somehow because of queue in match clause.

Is it possible to pass arguments, in second line, in where clause and keep also there relation between queue and person -[:queue_person]-> (pr) like in below not working snippet query?

WHERE (:Queue {name in ['A','B']) -[:queue_person]-> (pr)