I'm working with prepared statements via the Neo4J JDBC driver, and have a need to create node and relationship labels whose names are driven by the data we will be receiving.
For example, I'd like to create a prepared statement along these lines:
MERGE (test:{1} {id: {2}) ON CREATE SET test.id = {2}
OR
MERGE (test:Test)-[:{1}]->(test2:Test)
These don't currently work, as it seems Neo4J doesn't interpret the placeholder {1}
as a placeholder, instead seeing it as an invalid label name.
Another possibility I'm exploring is that we may be able to extend Cypher via a stored procedure, though I suspect we may run into the same limitation.
Hoping someone can provide some insight as to whether there is any way to accomplish this with Cypher.
Thanks!
UPDATE:
An answer below suggests using APOC's apoc.create.node
procedure, but what I need is to merge on a dynamic label. Updated the title to reflect this.