neo4j / neo4j-go-driver

Neo4j Bolt Driver for Go
Apache License 2.0
494 stars 70 forks source link

Get data in graph format directly #402

Closed gschurck closed 2 years ago

gschurck commented 2 years ago

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.

fbiville commented 2 years ago

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:

gschurck commented 2 years ago

Okay thank you.

gschurck commented 2 years ago

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.

gschurck commented 2 years ago

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.