Dynamic property value based on query

Is there any way to add a dynamic node property that is calculated at query time?

e.g. for nodes Alice and Bob, if there is a relationship of type "LOVES" between Alice and Bob then a dynamic property "description" could return value "Alice loves Bob"

based on a query below

MATCH p=(a)-[r]->(b) WITH r, apoc.text.format("%s %s %s", [a.label,apoc.text.replace(toLower(type(r)),'_',' '),b.label]) AS output SET r.description = output RETURN id(r), output

Obviously I can store this as a static property but wondering if possible to generate this at query time rather than storing in db or processing in a client. I can't see any way to set up this as a stored procedure or otherwise. Is this kind of thing doable?

Hi @michela ,

If I understand correctly, you're describing the difference between a spreadsheet cell which contains a value versus one that has a formula introduced with =. Is that right?

Some day that might be possible by defining a view on the graph.

Until then, you could write a user-defined-function which accepts a path as a parameter and returns a map of values. See UserFunction (Neo4j 4.2.19 API)