neo4j/neo4j-go-driver

Get data in graph format directly

gschurck opened this issue · 4 comments

Is it possible to get the result of a cypher query in graph format directly, like in the HTTP API ?
For example to return the graph directly from the backend to display a graph visualization on the frontend.

Hello, there is no built-in support for this.
If you need help implementing this, I'm happy to continue the conversation on Discord: https://neo4j.com/developer/discord/.
Once you get a Result or ResultWithContext, you'll need to call, in order:

  • Keys
  • loop of (Next+Record or NextRecord) or just Collect
  • if you're calling Record or NextRecord, call and act upon the result of Err at the end of the iteration
  • Consume

Okay thank you.

Could it be an interesting feature to add in a PR for this driver ? I think it would be useful to have it as build-in.
For example in the Python driver there is graph and data functions to get a more ordered format directly.

Finally, I found that it's possible to export the graph data as JSON with cypher query directly

CALL apoc.export.json.all(null,{useTypes:true, stream: true, jsonFormat: "JSON"})
YIELD data
RETURN data

So it seems that it's the optimal way for an API to get neo4j graph data as JSON and return it directly in response.