I have been usingWithParams with neo4j client for c# but withParams don't work for label or relationship types for example.
The alternative I thought of the moment was to concatenate my string that I want to form based on some label as parameter and then construct the cypher query. That is:
string optionalMatchString = $"p =(n1)-[{relationshipsString}]-(n2)";
graphClient.Cypher.Match("(n1)")
.Where((Node n1) => n1.Identifier == identifier)
.OptionalMatch(optionalMatchString)
As you can guess, relationshipsString is a parameter passed to me. If I use WithParams the query will not substitute the parameters so for now I concatenate the string but this is vulnearble to attacks ... (yes?)
I learned about APOC and saw this issue
This is an example I saw this:
CALL db.labels() yield label
call apoc.cypher.run("MATCH (n:`"+label+"`) RETURN keys(n) as keys LIMIT 1",{}) yield value as row
RETURN label, row.keys as keys
Apparently, there is an APOC procedure called cypher.run
in which I can put my labels (or relationships for that matter) as variables (from the parameters) but from what I see, they are just concatenating a string... so is that the same as what I have been doing? or does APOC somehow perform other stuff on top of the query? Would that APOC procedure be "safe" against injections?