Neo4j is a graph database. It stores data as nodes connected by relationships and queries them with the Cypher language, which makes questions about connections, such as recommendations, fraud rings, or supply chains, fast to answer. AuraDB is Neo4j's fully managed cloud service.
How does the integration work?
The Query Neo4j AuraDB function template shows how to work with a graph database from Appwrite Functions. Each GET request to the function:
- Creates a
Warehousenode with a random location and capacity. - Links it to a
Categorynode, such aselectronicsorfurniture, with aSTORESrelationship, creating the category only if it doesn't exist yet. - Returns up to 100 warehouse and category pairs as JSON.
The function keeps its driver connection between executions, so warm requests skip the connection setup. Use it as a starting point for your own Cypher queries.
How to implement
To implement the Neo4j AuraDB integration, there are several steps you must complete:
Step 1: Create an AuraDB instance
Sign in to the Neo4j Aura console and create an AuraDB instance. When Aura shows the instance's credentials, download or copy them, because the password isn't shown again. The credentials include:
| Value | Example |
|---|---|
| Connection URI | neo4j+s://<INSTANCE_ID>.databases.neo4j.io |
| Username | neo4j |
| Password | The generated password |
Wait until the instance is running before you continue.
Step 2: Create the Appwrite Function
For this step, you must create an account on Appwrite Cloud or self-host Appwrite if you haven't already. If you self-host Appwrite, enable a Node.js runtime in _APP_FUNCTIONS_RUNTIMES and follow the Functions configuration guide so function domains work.
In the Appwrite Console, go to Functions, open the Templates tab, search for Query Neo4j AuraDB, and click Create from template. Fill in the Template variables:
| Variable | Value |
|---|---|
NEO4J_URI | The connection URI |
NEO4J_USER | The username |
NEO4J_PASSWORD | The password |
Choose Connect your repository to clone the template into a Git repository where you can write your own queries, or Connect later to deploy it right away. Then click Create and deploy.
Step 3: Test the function
Copy the function's domain from the Domains tab and send a request:
curl https://<FUNCTION_DOMAIN>The response contains the query's records, each with a Warehouse node and its Category node. Every request adds another warehouse, so the list grows as you call the function. Requests with other methods return 404.
To see the graph, open your instance in the Aura console and run:
MATCH (w:Warehouse)-[:STORES]->(c:Category) RETURN w, cThe template allows anyone to execute the function, so anyone who finds its domain can add warehouses to your database. Before you query your own data, replace Any in the function's execute access with narrower roles, such as Users, and call the function with an Appwrite SDK instead of its domain.
Read more about Neo4j and Appwrite Functions
If you would like to learn more about Neo4j and Appwrite Functions, we have some resources that you should visit:
