I'm trying to return the Node object in my tree query.
type Node {
ID: ID!
name: String
child: [Child]
}
type Child @relation(name: "CHILD_OF") {
from: Node #child
to: Node #parent
index: String
}
type Tree {
path: String
name: String
indent: Int
childCount: Int
node:[Node] // return the Node object
}
type Query {
tree(root: String):[Tree]
@cypher(statement:
"""MATCH p = (:Node { name: $root })<-[:CHILD_OF *0..]-(c:Node)
WITH c, apoc.text.join('1' + [rel in relationships(p) | rel.index], '.') as path, size((c)<-[:CHILD_OF]-()) as childCount, c as Node
ORDER BY path
RETURN c { .name, path, childCount, indent: size(split(path,'.'))-1, Node}"""
)
}
Running the following in the playground:
query
{tree(root: "Root"){
path
indent
childCount
node{
name
}
}
}
Returns the following:
{
"errors": [
{
"message": "Cannot read property '0' of undefined",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"tree"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"stacktrace": [
"TypeError: Cannot read property '0' of undefined",
" at buildCypherSelection (/home/rchevalier/dev/grand-stack/api/node_modules/neo4j-graphql-js/dist/selections.js:315:20)",
" at recurse (/home/rchevalier/dev/grand-stack/api/node_modules/neo4j-graphql-js/dist/selections.js:87:33)",
" at buildCypherSelection (/home/rchevalier/dev/grand-stack/api/node_modules/neo4j-graphql-js/dist/selections.js:173:12)",
" at recurse (/home/rchevalier/dev/grand-stack/api/node_modules/neo4j-graphql-js/dist/selections.js:87:33)",
" at buildCypherSelection (/home/rchevalier/dev/grand-stack/api/node_modules/neo4j-graphql-js/dist/selections.js:173:12)",
" at recurse (/home/rchevalier/dev/grand-stack/api/node_modules/neo4j-graphql-js/dist/selections.js:87:33)",
" at buildCypherSelection (/home/rchevalier/dev/grand-stack/api/node_modules/neo4j-graphql-js/dist/selections.js:173:12)",
" at customQuery (/home/rchevalier/dev/grand-stack/api/node_modules/neo4j-graphql-js/dist/translate.js:558:68)",
" at translateQuery (/home/rchevalier/dev/grand-stack/api/node_modules/neo4j-graphql-js/dist/translate.js:501:12)",
" at cypherQuery (/home/rchevalier/dev/grand-stack/api/node_modules/neo4j-graphql-js/dist/index.js:141:40)"
]
}
}
}
],
"data": {
"tree": null
}
}
Any ideas what I'm doing wrong?