When calling a query module from a trigger statement, what I expected to get within a function was a state of the graph before the query changes occurred. However, this is not the case, and made changes are already visible in the graph state. I’ll write a dummy example of such behavior:
CREATE TRIGGER my_trigger ON CREATE
BEFORE COMMIT EXECUTE
CALL my_module.function(createdVertices, createdEdges) YIELD node, property
SET node.property = property;
Function my_module.function should execute after following statement:
MATCH (n {id: 19}), (m {id: 10}), (u {id: 14})
CREATE (n)-[new_edge_1:RELATION]->(m), (n)-[new_edge_2:RELATION]->(u)
In my_module.function, we’ll see a graph state with just created new_edge_1 and new_edge_2. If our calculation depends on having incremental changes, where we need the state of graph before any changes occur, is there a way to do it inside Memgraph with triggers?