Naive parser from graphql to cypher query.
main.js:
tape('user entity with address', (t) => {
t.plan(2)
parse(`
user(id: <id>) {
properties {
name,
address(edge: ":address", addressId: <addressId>) {
properties {
line
}
}
}
}
`, (err, r) => {
t.error(err)
t.equals(r.cql, expected)
})
var expected = `
match(user:user {id: {id}}) optional match(user)<-[:address]->(address:address {addressId: {addressId}})
return *
`
})
To see how reduce works to see how it looks check out fixtures, It works together with the module cypherquery
This requires that the statement sent to cypher has resultType
['row', 'graph']
]
You can ask for relationships in graphql
`
user(id: <id>) {
relationships,
...
`
You can ask for labels in graphql
`
user(id: <id>) {
labels
...
`
You can ask for the raw graph as returned by cypher
`
user(id: <id>) {
graph
...
`
With npm do:
npm install graphql2cypher
npm test
MIT