Execute Cypher Query
AI-generatedOverview
This node allows users to execute Cypher queries against a Neo4j graph database. It is designed for interacting with Neo4j, enabling retrieval and manipulation of graph data through custom Cypher commands. Common use cases include querying nodes and relationships, updating graph structures, or running complex graph algorithms directly from an n8n workflow.
For example, you might use this node to:
- Retrieve a subset of nodes matching certain criteria.
- Create or update nodes and relationships in the graph.
- Run analytical queries that return aggregated graph metrics.
The "Execute Cypher Query" operation provides flexibility by allowing any valid Cypher query to be run, making it suitable for both read-only and write operations on the graph.
Properties
| Name | Meaning |
|---|---|
| Cypher Query | The Cypher query string to execute. This is the core input where you specify your graph query. |
| Options | Additional settings for query execution: |
| - Transaction Type | Defines how the transaction is handled: • Auto-Detect (Read/Write): Automatically detects if the query is read or write based on keywords like CREATE, MERGE, SET, DELETE, REMOVE. • Read: Forces the query to run as a read transaction. • Write: Forces the query to run as a write transaction. |
Output
The node outputs the results of the executed Cypher query in the json field of the output items. Typically, this will be an array of objects representing the records returned by the query, such as nodes, relationships, or other data structures depending on the query.
If the query returns graph entities, these are usually serialized into JSON format showing their properties and identifiers.
The node does not explicitly mention binary data output, so it can be assumed that all output is JSON-formatted data representing the query results.
Dependencies
- Requires a connection to a Neo4j database instance.
- Needs an API key credential or authentication token configured in n8n to authorize access to the Neo4j database.
- The node depends on the Neo4j driver or API client internally (bundled within the node's codebase).
Troubleshooting
Common issues:
- Invalid Cypher syntax: Ensure your query is correctly formatted according to Neo4j Cypher language rules.
- Authentication errors: Verify that the API key or credentials provided have correct permissions and are valid.
- Transaction type mismatch: If auto-detection fails, try explicitly setting the transaction type to "read" or "write".
- Connection failures: Check network connectivity and Neo4j server availability.
Error messages:
- "Authentication failed": Check credentials and API key validity.
- "Syntax error in Cypher query": Review and correct the Cypher query syntax.
- "Transaction type not supported": Adjust the transaction type option accordingly.