Search code examples
cyphergremlinamazon-neptuneopencypher

Multiple versions of the graph


Currently, I am working on an application that allows the user to display graph-related data visually. Users can then make specific edits on the graph:

  • adding a link between nodes

  • adding new node

  • changing specific attributes of the node

  • removing link

Those edits should be only visible on the "custom graph" edited by the user. Users can have multiple "versions" of the graph on which we added specific edits.

Is there any functionality in Neptune that could help us to achieve such functionality (we were also using Neo4j)? We can see it as having multiple views of the same graph with specific edits.

My current approach is to store the "edits" in a separate database (relational or NoSQL) and when the user wants to display a graph:

  1. First, I fetch the unedited version from Neptune

  2. Secondly, we fetch the metadata about user edits and apply them to the data before returning them to the frontend application

I would like to know whether someone had a similar problem and if you have thoughts about this solution. The solution may be similar to event storing - when we apply the events to get the final view of the graph.


Solution

  • I think your approach sounds reasonable. In some ways this is a bit like editing an image with layers, where the actual image is only updated when the layers are committed and flattened back into being a single image.

    Amazon Neptune does not have such a "layer" mechanism per-se. So you will need to keep the edits somehow in a way that is managed by the application.

    You could add them to the graph but with some token (like a property or ID) that you know is temporary and then delete them later if you do not want the edits completely persisted.

    If you do not want to allow even temporary edits to the actual graph, then maintaining the change history in some other way, managed by the application, seems like the way to go here.