---
schema_version: "1"
id: 517fc28a9b330a6433675d34aa7163302579a5b33a95d792362bac6b58333878
title: Neo4j Connector
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/neo4j-connector/3.0/index.md
canonical_url: https://docs.mulesoft.com/neo4j-connector/3.0/
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 52f57efc58d2e82d147df93c86766978ee31cf32cb8cfe940c56cd0660006bac
description: MuleSoft Documentation Site
release: "3.0"
latest: false
---
---
product: Neo4j Connector
version: 3.0
---

# Neo4j Connector

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

Neo4j Connector v3.0

Anypoint Connector for Neo4j provides the capability to execute CQL statements and run basic
operations, such as create, update, delete, and select nodes against a Neo4j Graph database
instance.

Release Notes:
[Neo4j Connector Release Notes](https://docs.mulesoft.com/release-notes/connector/neo4j-connector-release-notes-mule-4)  
Exchange:
[Neo4j Connector](https://www.mulesoft.com/exchange/com.mulesoft.connectors/mule-neo4j-connector/)

## Before You Begin

To use this information, you need to be familiar with Neo4j, Mule, Anypoint Connectors, Anypoint
Studio, Mule concepts, elements in a Mule flow, and Global Elements.

You need login credentials to test your connection to your target resource.

For software requirements and compatibility information, see the Connector Release Notes.

## POM File Information

```xml
<dependency>
  <groupId>com.mulesoft.connectors</groupId>
  <artifactId>mule-neo4j-connector</artifactId>
  <version>x.x.x</version>
  <classifier>mule-plugin</classifier>
</dependency>
```

Replace `x.x.x` with the version that corresponds to the connector you are using.

To obtain the most up-to-date `pom.xml` file information, access the connector in
[Anypoint Exchange](https://www.mulesoft.com/exchange/) and click **Dependency Snippets**.

## Metadata

Neo4j connector metadata is based on the following premises:

- Labels listed on operations are the labels that are instanced in the database.

- The database has these constraints for its nodes:

  - Unique property constraints.

  - Property existence constraints.

  - At least one node with constraint values defined in the database.

## Add the Connector to a Studio Project

Anypoint Studio provides two ways to add the connector to your Studio project: from the Exchange
button in the Studio taskbar or from the Mule Palette view.

### Add the Connector Using Exchange

1.  In Studio, create a Mule project.

2.  Click the Exchange icon **(X)** in the upper-left of the Studio task bar.

3.  In Exchange, click **Login** and supply your Anypoint Platform username and password.

4.  In Exchange, search for "neo4j".

5.  Select the connector and click **Add to project**.

6.  Follow the prompts to install the connector.

### Add the Connector in Studio

1.  In Studio, create a Mule project.

2.  In the Mule Palette view, click **(X) Search in Exchange**.

3.  In **Add Modules to Project**, type "neo4j" in the search field.

4.  Click this connector’s name in **Available modules**.

5.  Click **Add**.

6.  Click **Finish**.

### Configure in Studio

1.  Drag a Neo4j operation to the Studio Canvas.

2.  Select the operation.

    ![List of available operations in Studio for Neo4j connector](/mulesoft/current/en-us/neo4j-connector/3.0/_images/neo4j-operations-studio.png)

    <table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><strong>Execute</strong></p></td><td><div><div><p>Execute any CQL statement against DB.</p></div></div></td></tr><tr><td><p><strong>Create Node</strong></p></td><td><div><div><p>Create a node with a specific initial label. Optionally, properties for the node can be added.</p></div></div></td></tr><tr><td><p><strong>Select Nodes</strong></p></td><td><div><div><p>Query nodes with a specific label. Optionally, properties used as filter can be provided.</p></div></div></td></tr><tr><td><p><strong>Update Nodes</strong></p></td><td><div><div><p>Modified properties for one or multiple nodes with a specific label. Optional Properties can be added as search filter criteria.</p></div></div></td></tr><tr><td><p><strong>Delete Nodes</strong></p></td><td><div><div><p>Delete one or multiples nodes based on a specific label. This lets you delete nodes with inbound/outbound relationships. Optional Properties can be added as search filter criteria.</p></div></div></td></tr></tbody></table>

    Note: The Neo4j connector’s basic operations can filter nodes by only one label in its query. If
    you want to filter in a query by multiple labels, use the Execute operation with a proper CQL
    statement.

3.  Configure the Global element for the connector.

    ![Global elements properties window](/mulesoft/current/en-us/neo4j-connector/3.0/_images/neo4j-config-studio1.png)

    <table><colgroup><col> <col></colgroup><thead><tr><th>Field</th><th>Description</th></tr></thead><tbody><tr><td><p><strong>Username</strong></p></td><td><div><div><p>Enter the username to log in with.</p></div></div></td></tr><tr><td><p><strong>Password</strong></p></td><td><div><div><p>Enter the corresponding password.</p></div></div></td></tr><tr><td><p><strong>BOLT URL</strong></p></td><td><div><div><p>Bolt endpoint.</p></div></div></td></tr><tr><td><p><strong>REST URL</strong></p></td><td><div><div><p>Rest endpoint URL (works with HTTP or HTTPS).</p></div></div></td></tr></tbody></table>

## Use Case: Node Basic CRUD

![Studio flow with Listener, Transform Message, Create node, Select nodes, Delete node, and Transform Message](/mulesoft/current/en-us/neo4j-connector/3.0/_images/neo4j-example-flow.png)

1.  Create a new Mule Project in Anypoint Studio and set your Neo4j environment properties in
    `src/main/resources/automation-credentials.properties`.

    ```text
    config.username=<USERNAME>
    config.password=<PASSWORD>
    config.boltUrl=<BOLT_URL_ENDOPOINT>
    config.restUrl=<REST_URL_ENDPOINT>
    ```

2.  Drag an HTTP connector onto the canvas and configure it with the default values.

3.  Drag a Transform Message onto the canvas and create a flowVar called params with the following
    code:

    ```dataweave
    %dw 2.0
    %output application/json
    ---
    {
    	"name":"Tom Hanks",
    	"born": 1956
    }
    ```

4.  Drag the Neo4j connector onto the canvas and configure a new global element according to the
    table below:

    <table><colgroup><col> <col></colgroup><thead><tr><th>Parameter</th><th>Value</th></tr></thead><tbody><tr><td><p><strong>Username</strong></p></td><td><div><div><p><code>${neo4j.username}</code></p></div></div></td></tr><tr><td><p><strong>Password</strong></p></td><td><div><div><p><code>${neo4j.password}</code></p></div></div></td></tr><tr><td><p><strong>BOLT URL</strong></p></td><td><div><div><p><code>${neo4j.boltUrl}</code></p></div></div></td></tr><tr><td><p><strong>REST URL</strong></p></td><td><div><div><p><code>${neo4j.restUrl}</code></p></div></div></td></tr></tbody></table>

    ```xml
    <neo4j:config name="Neo4j_Config" doc:name="Neo4j Config">
    	<neo4j:connection username="${config.username}"
    	password="${config.password}"
    	boltUrl="${config.boltUrl}"
    	restUrl="${config.restUrl}" />
    	</neo4j:config>
    </neo4j:config>
    ```

5.  In the Properties Editor, configure:

    <table><colgroup><col> <col></colgroup><thead><tr><th>Parameter</th><th>Value</th></tr></thead><tbody><tr><td><p><strong>Display Name</strong></p></td><td><div><div><p>Create node</p></div></div></td></tr><tr><td><p><strong>Connector Configuration</strong></p></td><td><div><div><p>Neo4j__Basic_Authentication</p></div></div></td></tr><tr><td><p><strong>Operation</strong></p></td><td><div><div><p>Create node</p></div></div></td></tr><tr><td><p><strong>Label</strong></p></td><td><div><div><p>Person</p></div></div></td></tr><tr><td><p><strong>Parameters Reference</strong></p></td><td><div><div><p><code>#[payload]</code></p></div></div></td></tr></tbody></table>

    ![Create node properties configuration window](/mulesoft/current/en-us/neo4j-connector/3.0/_images/neo4j-create-node.png)

    Note: Click Test Connection to confirm that Mule can connect with the Neo4j instance. If the
    connection is successful, click OK to save the configuration. Otherwise, review or correct any
    invalid parameters and test again.

6.  Drag a Neo4j connector onto the canvas, in the Properties Editor, configure the parameters:

    <table><colgroup><col> <col></colgroup><thead><tr><th>Parameter</th><th>Value</th></tr></thead><tbody><tr><td><p><strong>Operation</strong></p></td><td><div><div><p>Select nodes</p></div></div></td></tr><tr><td><p><strong>Label</strong></p></td><td><div><div><p>Person</p></div></div></td></tr></tbody></table>

7.  Drag a Neo4j connector onto the canvas, in the Properties Editor, configure the parameters:

    <table><colgroup><col> <col></colgroup><thead><tr><th>Parameter</th><th>Value</th></tr></thead><tbody><tr><td><p><strong>Operation</strong></p></td><td><div><div><p>Delete nodes</p></div></div></td></tr><tr><td><p><strong>Label</strong></p></td><td><div><div><p>Person</p></div></div></td></tr></tbody></table>

8.  Drag an Transform Message onto the canvas.

    ```dataweave
    %dw 2.0
    %output application/json
    ---
    payload
    ```

9.  Save the changes and deploy the project as a Mule Application. Open a browser and make a request
    to the following URL:

    ```none
    http://localhost:8081/CRUD
    ```

    If the node was successfully created and deleted, information displays in a JSON format:

    ```json
    { "born": 1956, "name": "Tom Hanks" }
    ```

### Create a Node with Multiple Labels

![Studio flow with Listener, Transform Message, Create node, Select node, and Transform Message](/mulesoft/current/en-us/neo4j-connector/3.0/_images/neo4j-create-node-with-multiple-labels.png)

1.  Create a new Mule Project in Anypoint Studio and set your Neo4j environment properties in
    `src/main/resources/automation-credentials.properties`.

    ```text
    config.username=<USERNAME>
    config.password=<PASSWORD>
    config.boltUrl=<BOLT_URL_ENDOPOINT>
    config.restUrl=<REST_URL_ENDPOINT>
    ```

2.  Drag an HTTP connector onto the canvas and configure it with the default values.

3.  Drag a Transform Message onto the canvas and create two flowVars with the following code:

    1.  Variable-create

        ```dataweave
        %dw 2.0
        %output application/json
        ---
        "CREATE (a:ACTOR:PERSON { name:\"Tom Hanks\", born:1956 })"
        ```

    2.  Variable-select

        ```dataweave
        %dw 2.0
        %output application/json
        ---
        "MATCH (a:ACTOR:PERSON) RETURN a"
        ```

4.  Drag the Neo4j connector onto the canvas and configure a new Global Element according to the
    table below:

    <table><colgroup><col> <col></colgroup><thead><tr><th>Parameter</th><th>Value</th></tr></thead><tbody><tr><td><p><strong>Username</strong></p></td><td><div><div><p><code>${neo4j.username}</code></p></div></div></td></tr><tr><td><p><strong>Password</strong></p></td><td><div><div><p><code>${neo4j.password}</code></p></div></div></td></tr><tr><td><p><strong>BOLT URL</strong></p></td><td><div><div><p><code>${neo4j.boltUrl}</code></p></div></div></td></tr><tr><td><p><strong>REST URL</strong></p></td><td><div><div><p><code>${neo4j.restUrl}</code></p></div></div></td></tr></tbody></table>

    ```xml
    <neo4j:config name="Neo4j_Config" doc:name="Neo4j Config">
    	<neo4j:connection username="${config.username}"
    	password="${config.password}"
    	boltUrl="${config.boltUrl}"
    	restUrl="${config.restUrl}" />
    	</neo4j:config>
    </neo4j:config>
    ```

5.  In the Properties Editor, configure:

    <table><colgroup><col> <col></colgroup><thead><tr><th>Parameter</th><th>Value</th></tr></thead><tbody><tr><td><p><strong>Display Name</strong></p></td><td><div><div><p>Create node (advanced)</p></div></div></td></tr><tr><td><p><strong>Connector Configuration</strong></p></td><td><div><div><p>Neo4j__Basic_Authentication</p></div></div></td></tr><tr><td><p><strong>Operation</strong></p></td><td><div><div><p>Execute</p></div></div></td></tr><tr><td><p><strong>Query</strong></p></td><td><div><div><p><code>#[vars.create]</code></p></div></div></td></tr><tr><td><p><strong>Parameters Reference</strong></p></td><td><div><div><p><code>#[payload]</code></p></div></div></td></tr></tbody></table>

    ![Create node properties configuration window](/mulesoft/current/en-us/neo4j-connector/3.0/_images/neo4j-execute-create.png)

    Click Test Connection to confirm that Mule can connect with the Neo4j instance. If the
    connection is successful, click OK to save the configuration. Otherwise, review or correct any
    invalid parameters and test again.

6.  Drag a Neo4j connector onto the canvas, in the Properties Editor, configure the parameters:

    <table><colgroup><col> <col></colgroup><thead><tr><th>Parameter</th><th>Value</th></tr></thead><tbody><tr><td><p><strong>Display Name</strong></p></td><td><div><div><p>Select node (Multi-label)</p></div></div></td></tr><tr><td><p><strong>Operation</strong></p></td><td><div><div><p>Execute</p></div></div></td></tr><tr><td><p><strong>Query</strong></p></td><td><div><div><p><code>#[vars.select]</code></p></div></div></td></tr></tbody></table>

7.  Drag a Transform Message onto the canvas.

8.  Drag a Logger onto the canvas.

9.  Save the changes and deploy the project as a Mule Application. Open a browser and make a request
    to the following URL:

    ```none
    http://localhost:8081/createNodeMultiLabel
    ```

    If the node was successfully created and deleted, information displays in a JSON format:

    ```json
    [{ "a": { "born": 1956, "name": "Tom Hanks" } }]
    ```

## Use Case: XML

```xml
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:neo4j="http://www.mulesoft.org/schema/mule/neo4j"
	xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
	xmlns:http="http://www.mulesoft.org/schema/mule/http"
	xmlns="http://www.mulesoft.org/schema/mule/core"
	xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core
	http://www.mulesoft.org/schema/mule/core/current/mule.xsd
	http://www.mulesoft.org/schema/mule/http
	http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
	http://www.mulesoft.org/schema/mule/ee/core
	http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
	http://www.mulesoft.org/schema/mule/neo4j
	http://www.mulesoft.org/schema/mule/neo4j/current/mule-neo4j.xsd">
	<http:listener-config name="HTTP_Listener_config"
	doc:name="HTTP Listener config" basePath="/" >
		<http:listener-connection host="0.0.0.0" port="8081" />
	</http:listener-config>
	<neo4j:config name="Neo4j_Config" doc:name="Neo4j Config">
		<neo4j:connection username="${config.username}"
		 password="${config.password}" boltUrl="${config.boltUrl}"
		 restUrl="${config.restUrl}" />
	</neo4j:config>
	<flow name="CRUD" >
		<http:listener doc:name="Listener"
		 config-ref="HTTP_Listener_config" path="/CRUD"/>
		<ee:transform doc:name="Transform Message" >
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
	"name":"Tom Hanks",
	"born": "1956"
}]]></ee:set-payload>
			</ee:message>
		</ee:transform>
		<neo4j:create-node label="Person" doc:name="Create node"
		 config-ref="Neo4j_Config" input="#[payload]"/>
		<neo4j:select-nodes label="Person" doc:name="Select nodes"
		 config-ref="Neo4j_Config" input="#[payload]"/>
		<neo4j:delete-nodes label="Person" doc:name="Delete nodes"
		 config-ref="Neo4j_Config" parameters="#[payload]"/>
		<ee:transform doc:name="Transform Message">
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
			</ee:message>
		</ee:transform>
	</flow>
	<flow name="createNodeWithMultiLabels">
		<http:listener doc:name="Listener"
		config-ref="HTTP_Listener_config"
		path="/createNodeMultiLabel"/>
		<ee:transform doc:name="Transform Message">
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
output application/java
---
{

}]]></ee:set-payload>
			</ee:message>
			<ee:variables >
				<ee:set-variable variableName="select" ><![CDATA[%dw 2.0
output application/json
---
"MATCH (a:ACTOR:PERSON) RETURN a"]]></ee:set-variable>
				<ee:set-variable variableName="create" ><![CDATA[%dw 2.0
output application/json
---
"CREATE (a:ACTOR:PERSON { name:\"Tom Hanks\", born:1956 })"]]></ee:set-variable>
			</ee:variables>
		</ee:transform>
		<neo4j:execute doc:name="Create node (advanced)" config-ref="Neo4j_Config" input="#[payload]">
			<neo4j:query ><![CDATA[#[vars.create]]]></neo4j:query>
		</neo4j:execute>
		<neo4j:execute doc:name="Select node (Multi-label)"  config-ref="Neo4j_Config">
			<neo4j:query ><![CDATA[#[vars.select]]]></neo4j:query>
		</neo4j:execute>
		<ee:transform doc:name="Transform Message">
			<ee:message >
				<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
			</ee:message>
		</ee:transform>
	</flow>
</mule>
```

## See Also

- [Neo4j Connector Reference](https://docs.mulesoft.com/neo4j-connector/3.0/neo4j-connector-reference)

- [Salesforce Help](https://help.salesforce.com)
