cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Why does an argument need to be passed with this query for it to work?

Hi,
im a fairly inexperienced coder so this question might be obvious to u guys.
Currently trying to set up the schema with makeAugmentedSchema, but I want to create the resolver functions and queries myself (both for a later purpose in the app but also just for practice and learning).

So the Q: Why does 1 work but not 2?

1.
openTrades(isOpen: Boolean): [Trade]
@cypher(
statement: "MATCH (t:Trade) WHERE t.isOpen = $isOpen RETURN t"
)

2.
openTrades: [Trade]
@cypher(
statement: "MATCH (t:Trade {isOpen: true}) RETURN t"
)

3 REPLIES 3

William_Lyon
Graph Fellow

Both look correct to me. Are they both fields on the Query type? Are you getting an error with the second option?

Yes they are both fields on the QueryType.

This is the error msg:

"message": "Invalid input ',': expected whitespace, comment or an expression (line 1, column 76 (offset: 75))\n"WITH apoc.cypher.runFirstColumn("MATCH (t:Trade {isOpen: true}) RETURN t", , True) AS x UNWIND x AS trade"\n

Ah - I believe that is related to this issue, which has been fixed in master and will be available in the next release.

The problem is that if a parameter is not specified then we don't insert a blank object resulting in a syntax error in the generated Cypher statement. The fix should be released in the next few days, but in the mean time you can avoid this error by ensuring a parameter is used, for example this should work:

openTrades(ignoreMe: String = ""): [Trade]
@cypher(
  statement: "MATCH (t:Trade {isOpen: true}) RETURN t"
)