Calling apoc procedure from Golang driver

I want to call apoc procedure from the golang driver. I can fire basic cypher queries from driver but while call apoc procedure it throws syntax error.

panic: An error occurred getting result of exec command: messages.FailureMessage{Metadata:map[string]interface {}{"code":"Neo.ClientError.Statement.SyntaxError", "message":"Invalid input '3': expected whitespace, '.', node labels, '[', \"=~\", IN, STARTS, ENDS, CONTAINS, IS, '^', '*', '/', '%', '+', '-', '=', '~', \"<>\", \"!=\", '<', '>', \"<=\", \">=\", AND, XOR, OR, ',' or ')' (line 1, column 74 (offset: 73))\n\"call apoc.export.json.query(\"MATCH t = (p)-[:has*0..] -> (i:node{`name`:\"39\"}) return p;\",\"2.json\")\"\n

Are you sure backticks around name is the right way to escape within apoc for golang? Seems like The error message is pointing toward that.

Thank you @terryfranklin82. I tried removing backticks and still, I am getting the same error.

call apoc.export.json.query("MATCH t = (p)-[:has*0..] -> (i:node{name:"39"}) return p;","1.json")

I want to fire the above query from golang. Basically, golang wants me to pass the query as a string. Here the query itself contains a nested string in it. I think the error is due to that. Below is the syntax I am using to query from golang.

conn.PrepareNeo("call apoc.export.json.query(\"MATCH t = (p)-[:has*0..] -> (i:node{name:\"39\"}) return p;\",\"1.json\"")

What about removing the whitespace in your match spec


does that help?

@terryfranklin82. Thanks for reviewing.
I removed the whitespaces but that fails.

Updated query from golang.

stmt, err := conn.PrepareNeo("call apoc.export.json.query(\"MATCH t=(p)-[:has*0..]->(i:node{name:\"39\"})return p;\",\"1.json\")")

Output when I print the stmt.

&{[] call apoc.export.json.query("MATCH t=(p)-[:has*0..]->(i:node{name:"39"})return p;","1.json") 0xc0000a6000 false <nil>}

The error which I am getting now.

panic: Neo4J reported a failure for the query
Internal Error(messages.FailureMessage):messages.FailureMessage{Metadata:map[string]interface {}{"code":"Neo.ClientError.Statement.SyntaxError", "message":"Invalid input '3': expected whitespace, '.', node labels, '[', \"=~\", IN, STARTS, ENDS, CONTAINS, IS, '^', '*', '/', '%', '+', '-', '=', '~', \"<>\", \"!=\", '<', '>', \"<=\", \">=\", AND, XOR, OR, ',' or ')' (line 1, column 68 (offset: 67))\n\"call apoc.export.json.query(\"MATCH t=(p)-[:has*0..]->(i:node{name:\"39\"})return p;\",\"1.json\")\"\n 

Maybe try with the relationship whitespace removed and the backticks added in again?

It's definitely a syntax error of some kind. Escaping cypher within a function call can be a bit tricky to begin with, but once you get the pattern it's easier to follow.

@terryfranklin82, I tried many combinations. It still fails :slightly_frowning_face: