Cypher query to dynamically match parameter in apoc call

Viewed 382

I am using a query of the following structure

MATCH path=((:Start)-[:NEXT*..100]->(n))
WHERE ALL(mnode IN nodes(path)
    WHERE mnode.minimum <= $data[mnode.checkagainst])

where data is something like {checkparam1: 24}. What this does for me is: the name of the parameter against which I want to check the minimum resides in the node.

All is working fine, however when I build in apoc stuff like

MATCH path=((:Start)-[:NEXT*..100]->(n))
WHERE ALL(mnode IN nodes(path)
    WHERE mnode.minimum <= apoc.date.toYear($data[mnode.checkagainst]))

it tells me

Failed to invoke function `apoc.date.toYears`: Caused by: java.lang.NullPointerException

I suspect that I can't rely on "information from the query memory" inside the apoc call, because when I manually fill in the value of mnode.checkagainst like

MATCH path=((:Start)-[:NEXT*..100]->(n))
WHERE ALL(mnode IN nodes(path)
    WHERE mnode.minimum <= apoc.date.toYear($data['checkparam1']))

the apoc call works. Not sure whether this is intended behaviour?

Any suggestions for a workaround?

1 Answers
Related