Skip to content
Graph docs0.5

Neo4j and Memgraph

Latest stable Based on Graph release 0.5.1

Backend decision map

Both modules use Neo4j-driver-compatible Bolt and Cypher, so they share much application code. They remain separate backends because server behavior, supported Cypher, schema DDL, deployment, and operational signals differ.

Choose Neo4j when Neo4j is already operated or its transaction/schema behavior is the reference requirement. Start at Neo4jGraphOperations.kt, then verify batch, merge, schema, and suspend transaction behavior in the neighboring tests.

Choose Memgraph when Memgraph is already deployed and its streaming/in-memory operational model fits the workload. The adapter is MemgraphGraphOperations.kt; schema behavior is explicit in MemgraphGraphSchemaManager.kt and its tests.

Run the container tests against the exact server line used in deployment. Observe connection-pool saturation, transaction retries/rollback, query latency, and server logs. A query passing on one server is not proof that its schema statements or edge cases are portable to the other.

dependencies {
implementation(platform("io.github.bluetape4k:bluetape4k-dependencies:<ecosystem-version>"))
implementation("io.github.bluetape4k:bluetape4k-graph-neo4j") // or ...-memgraph
}

The release fixtures create the driver and server; run them independently so one container lifecycle cannot mask the other:

Terminal window
./gradlew :bluetape4k-graph-neo4j:test --tests '*Neo4jGraphOperationsTest'
./gradlew :bluetape4k-graph-memgraph:test --tests '*MemgraphGraphOperationsTest'

Inside either fixture, execute the same facade calls:

val alice = ops.mergeVertex("Person", mapOf("email" to "a@example.com"), mapOf("name" to "Alice"))
val again = ops.mergeVertex("Person", mapOf("email" to "a@example.com"), mapOf("name" to "A. Example"))
check(alice.id == again.id)
check(ops.countVertices("Person") == 1L)

Observe semantic differences and lifecycle

Section titled “Observe semantic differences and lifecycle”

Expected: native merge preserves one identity and applies new set properties. Then inject an exception inside transaction { createVertex(...); error("rollback") }; the post-transaction count must stay unchanged. Run each backend’s schema-manager test as well. If CRUD passes but schema fails, compare the generated DDL and server version rather than treating driver compatibility as schema compatibility. Close the operations object created by the fixture and let the fixture stop its container; an externally supplied Driver remains caller-owned.