#
Idempotency
Idempotency ensures that running the data connector multiple times with the same data results in the same graph state, without creating duplicates.
#
Deterministic Keys
The most important factor is using deterministic keys for your nodes. Instead of using database auto-increments or random GUIDs, use unique identifiers from your source data.
// GOOD: Using a stable ID from the source
var supportCaseNode = graph.TryAdd(new Nodes.SupportCase() {
Id = sourceCase.ReferenceNumber, // Stable ID
Summary = sourceCase.Summary
});
#
Hash-based Keys
If your source data doesn't have a unique ID, you can generate a deterministic hash from its content.
string GenerateKey(SupportCase source) =>
HashUtils.ComputeMD5($"{source.CustomerEmail}|{source.Time:u}");
#
Handling Updates
If you need to update the properties of a node that might already exist, use graph.AddOrUpdate.
Unlike graph.TryAdd, which only creates the node if it's missing, graph.AddOrUpdate ensures that any changes to the properties in your source data are reflected in the graph. This is essential for "re-syncing" data where attributes might change over time.