File tree 1 file changed +41
-0
lines changed
1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,47 @@ This means that queries should fit on a single line.
88
88
You can replace line breaks with spaces, as Cypher parses them equivalently.
89
89
====
90
90
91
+
92
+ == Query parameters
93
+
94
+ Do not hardcode or concatenate parameters directly into queries.
95
+ Instead, always use placeholders and specify the link:{neo4j-docs-base-uri}/cypher-manual/current/syntax/parameters/[Cypher parameters].
96
+ This is for:
97
+
98
+ 1. *performance benefits*: Neo4j compiles and caches queries, but can only do so if the query structure is unchanged;
99
+ 2. *security reasons*: see link:https://neo4j.com/developer/kb/protecting-against-cypher-injection/[protecting against Cypher injection].
100
+
101
+ .Do -- Use query parameters
102
+ [source, JSON]
103
+ ----
104
+ {
105
+ "statements": [
106
+ {
107
+ "statement": "MERGE (n:Person {name: $name, age: $age}) RETURN n",
108
+ "parameters": {
109
+ "name": "Alice",
110
+ "age": 42
111
+ }
112
+ }
113
+ ]
114
+ }
115
+ ----
116
+
117
+ .Do not -- Embed literals in query
118
+ [source, JSON]
119
+ ----
120
+ {
121
+ "statements": [
122
+ {
123
+ "statement": "MERGE (n:Person {name: 'Alice', age: 42}) RETURN n",
124
+ }
125
+ ]
126
+ }
127
+ ----
128
+
129
+ See link:{neo4j-docs-base-uri}/cypher-manual/current/syntax/parameters/[Cypher Manual -> Parameters] for more information.
130
+
131
+
91
132
== Execute multiple queries
92
133
93
134
You can send multiple Cypher statements in the same request.
You can’t perform that action at this time.
0 commit comments