Array of objects cannot be used as parameter: Invalid input 'n': expected
When I do the following:
const rg = new Graph('mygraph')
try {
await rg.query('UNWIND $names AS name RETURN name.firstName', {
names: [{ firstName: 'Alice' }, { firstName: 'Bob' }]
})
} catch (e) {
console.error(e)
}
I'm getting the following error:
ReplyError: errMsg: Invalid input 'n': expected ';', a statement option, a query hint, a clause or a schema command line: 1, column: 1, offset: 0 errCtx: names=[[object Object], [object Object]] UNWIND $names AS name RETURN name.f... errCtxOffset: 0 at parseError (\node_modules\redis-parser\lib\parser.js:179:12) at parseType (\node_modules\redis-parser\lib\parser.js:302:14) { command: 'GRAPH.QUERY', args: [ 'blockchain', 'CYPHER names=[[object Object], [object Object]] UNWIND $names AS name RETURN name.firstName', '--compact' ] }
I guess the error occurs because [[object Object], [object Object]] is passed to the cypher query.
@mstimvol
map datatype is WIP https://github.com/RedisGraph/RedisGraph/pull/1514
once it is done and map as a parameter is supported your query will be valid.