Skip to content
Graph docs0.5

bluetape4k-graph-memgraph

Latest stable Based on Graph release 0.5.1

Memgraph uses the Neo4j Java Driver over Bolt but has its own server, Cypher subset, schema DDL, and operational model. Choose it when Memgraph is already deployed or its in-memory/streaming design fits the workload. Avoid using this adapter as proof of Neo4j parity. Source: MemgraphGraphOperations.kt.

Execution mode: release-fixture linked. The linked test starts the exact Memgraph image, creates Driver and ops, seeds data, and closes operations before Driver/container; its fixture is the source of endpoint and authentication settings.

dependencies {
implementation(platform("io.github.bluetape4k:bluetape4k-dependencies:<ecosystem-version>"))
implementation("io.github.bluetape4k:bluetape4k-graph-memgraph")
}
val driver = GraphDatabase.driver("bolt://localhost:7687", AuthTokens.none())
val ops = MemgraphGraphOperations(driver)
val a = ops.createVertex("Person", mapOf("name" to "Alice"))
val b = ops.mergeVertex("Person", mapOf("email" to "b@example.com"), mapOf("name" to "Bob"))
ops.createEdge(a.id, b.id, "KNOWS")
check(ops.neighbors(a.id, NeighborOptions(edgeLabel = "KNOWS")).single().id == b.id)
ops.close()
driver.close()

Expected: the Memgraph database returns the created neighbor. Use authentication matching the deployed server.

Transactions use the driver’s Memgraph session and must be tested against the deployed Memgraph version. Merge and batch queries are adapter-specific. Schema is implemented in MemgraphGraphSchemaManager.kt; never copy Neo4j DDL assumptions into it.

Operations do not close an injected Driver. Close sessions/operations first, then the caller-owned Driver.

  • Record server/image version and selected graph/database.
  • Watch connection-pool pressure and query latency.
  • Verify transaction rollback and schema capability separately.
  • Close operations before caller-owned Driver/DataSource.

Symptom: CRUD passes but schema or transaction assertions fail. Compare Memgraph server version and generated DDL, remove incompatible indexes/test data, and rerun the Memgraph-specific selector.

Diagnose network/authentication, database selection, query support, schema syntax, and transaction behavior separately. Observe pool pressure, query latency, memory, server logs, indexes, and rollback counts. If CRUD passes but schema fails, compare the generated Memgraph DDL and server version.

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

Expected: the Memgraph container passes CRUD and its own schema assertions. A Neo4j test cannot substitute for this command.

The pinned MemgraphGraphOperationsTest defines the fixture values and is the complete executable release example. Run:

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

Expected: the fixture starts, assertions pass, and owned resources close in the documented order.

See Neo4j and Memgraph, backend selection, and failure and cancellation. The module does not make Memgraph a uniform Neo4j superset, provision the server, or own the Driver.