Procedure return type

Hello everyone, I am having some problems with the Cypher procedures.
I want to return the graph that I get from executing a cypher query but I can't wrap my head around what type I need to return from my procedure method and what GraphDatabaseService method I need to execute to get that object. I am pretty sure it is a stream with a custom type containing the data I want to return but what is that precisely?
As my first try I am trying to return the base Hello World query that is included in the Basic Query scripts.

Here is an extract of my procedure method:

@Description("A test procedure that therurns HELLO WORLD!")
public Stream<MyTestResult> test(){
String query;
query = "CREATE (database:Database {name:"Neo4j"})-[r:SAYS]->(message:Message {name:"Hello World!"}) RETURN database, message, r";

Stream<MyTestResult> rStream = db.execute(query).stream().map(MyTestResult::new);

return rStream;

Thank you very much and sorry for the very simple question, I am quite a noob at this.


Hi Gustavo,

What error do you have with this code ?
Can you give the code of the MyTestResult class ?


1 Like

Sure, here is the code of the MyResult class:

public class MyTestResult {

public long nodeId;
public MyTestResult(Node node) {

this.nodeId = node.getId();

The error is that it cannot convert to type R.

Your cypher query returns a iterable of <Map<String, Object>. MyTestResult will need a constructor like,

public MyTestResult(Map<String, Object> onerow) {

That should resolve your syntax error


1 Like

Thank you Aldrin, I missed that detail!