UserFunction how to return org.neo4j.graphdb.Node from org.neo4j.graphdb.Result

Hello!

I'm trying to create UserFunction that executes CYPHER query and returns Node object.

Result result = db.execute(str_qry.toString())

How can i get org.neo4j.graphdb.Node from org.neo4j.graphdb.Result ?
Thank you!

what you need is to return a stream of a wrapping class for example

public Stream<MapResult> ..... {
    Result result = db.execute(str_qry.toString())
    return result .stream().map(NodeResult ::new)
}

and a NodeResult Class

import org.neo4j.graphdb.Node;
public class NodeResult {
    public final Node node;
    public NodeResult(Node node){this.node=node;}
    @Override
    public boolean equals (Object o){
        return  this  == o || o!=null && getClass()==o.getClass() && node.equals(((NodeResult)o).node);
    }

    @Override
    public int hashCode(){return node.hashCode();}
}

as a side note read this blog for tons and tons on info regarding procedures

reason: Incompatible types: Map<String, Object> is not convertible to Node

if you'd like to share more of your code i'd be happy to help. Please note that you must return a stream of value and types listed in the docs here.