Hi,
I'm trying to return an entire node as one of the properties of a type using custom directive @cypher available in the neo4j-graphql-js package, but I get this error in GraphQL Playground in the browser, when I try to access a property of this node:
"Variable `undefined` not defined (line 5, column 139 (offset: 424))\n\"RETURN {ability: ability{.*}, grade: grade} AS foo\", {this: student, cypherParams: $cypherParams}, true) | student_abilitiesPerformances {undefined}] } AS `student`\"\n ^"
These are my typeDefs:
type Student{
studentId: ID!
oldId: Int!
name: String!
abilitiesPerformances: [AbilityPerformance] @cypher (statement: """
match (this)-[a:ANSWERED]->(:Question)-[:DEVELOPS]->(ability:Ability)
with distinct ability, avg(a.fraction) as grade
order by grade desc
RETURN {ability: ability{.*}, grade: grade} AS foo
""")
}
type AbilityPerformance{
ability: Ability,
grade: Float
}
type Ability{
abilityId: ID!
oldId: Int!
name: String!
description: String
public: Boolean!
}
This is the GraphQL query I'm trying to run:
query{
Student(oldId: 4){
abilitiesPerformances{
ability{
name
}
}
}
}
But I get this error:

This is the generated cypher by neo4j-graphql.js:
MATCH (`student`:`Student` {oldId:$oldId}) RETURN `student` {abilitiesPerformances: [ student_abilitiesPerformances IN apoc.cypher.runFirstColumn("match (this)-[a:ANSWERED]->(:Question)-[:DEVELOPS]->(ability:Ability)
with distinct ability, avg(a.fraction) as grade
order by grade desc
RETURN {ability: ability{.*}, grade: grade} AS foo", {this: student, cypherParams: $cypherParams}, true) | student_abilitiesPerformances {undefined}] } AS `student`
{
"offset": 0,
"first": -1,
"oldId": 4,
"cypherParams": {}
}
I'm running [email protected].
This is my package.json:
{
"name": "grand-stack-starter-api",
"version": "0.0.1",
"description": "API app for GRANDstack",
"main": "src/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start:dev": "cross-env DEBUG=neo4j-graphql-js ./node_modules/.bin/nodemon --watch src --ext js,graphql --exec babel-node src/index.js",
"build": "babel src --out-dir build && shx cp .env build 2>/dev/null || : && shx cp src/schema.graphql build",
"now-build": "babel src --out-dir build && shx cp src/schema.graphql build",
"start": "npm run build && node build/index.js",
"seedDb": "./node_modules/.bin/babel-node src/seed/seed-db.js"
},
"author": "William Lyon",
"license": "MIT",
"dependencies": {
"apollo-boost": "^0.4.9",
"apollo-cache-inmemory": "^1.6.6",
"apollo-client": "^2.6.10",
"apollo-link-http": "^1.5.17",
"apollo-server": "^2.17.0",
"apollo-server-lambda": "^2.17.0",
"axios": "^0.20.0",
"cors": "^2.8.5",
"csv-parse": "^4.10.1",
"dotenv": "^7.0.0",
"express-jwt": "^6.0.0",
"graphql-tag": "^2.10.1",
"neo4j-driver": "^4.0.2",
"neo4j-graphql-js": "^2.14.2",
"node-fetch": "^2.6.0",
"graphql": "^14.7.0"
},
"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.0",
"@babel/node": "^7.8.7",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"@babel/preset-react": "^7.9.4",
"@babel/preset-typescript": "^7.9.0",
"@babel/runtime-corejs3": "^7.9.2",
"babel-plugin-auto-import": "^1.0.5",
"babel-plugin-module-resolver": "^4.0.0",
"cross-env": "^7.0.2",
"nodemon": "^1.19.1",
"shx": "^0.3.2"
}
}
What am I doing wrong here?
This is a currently known issue that arose recently with such nested object returns of @cypher fields, it's something I'm about to start working on in a few days - I'm sorry about the problem, it should be fixed up soon! 鉂わ笍
Thank you for the response, @michaeldgraham ! Give me a feedback when this is done, please.
Hi @michaeldgraham , any progress here?
Hi @michaeldgraham , is there a better place than here that I can check the progress of this issue? Because I need to provide feedback for my team since we are making big changes in our infrastructure.
@johnymontana , @michaeldgraham . Is there a way that I can help to solve this issue? Maybe a pull request with a correction proposal? Because this is being a big pain for us.
@CostaFernando Have you tried using an older version of the package? I do this process a lot and I'm on 2.14.0
Thank you for the response @benjamin-rood ! I just tried with versions [email protected] and [email protected] and I got the same error.
What version of neo4j-driver are you using? I'm using [email protected]. Maybe this could be a source of problem too.
@CostaFernando I'm on [email protected]
Weird, apparently it is not related with the neo4j-driver, then. @benjamin-rood , do you have some example using this in your application? Maybe I'm doing something wrong.
@CostaFernando @benjamin-rood I can confirm the same problem of not being able to return nested fields (Get the "variable 'undefined' not defined" error). I just needed that for a single query and so, did the required processing on the client side. Definitely not optimal, but it works for this simple case.
I am using [email protected] and [email protected]. However, since the problem seems to be in the cypher generated by neo4j-graphql.js, I would be very surprised if it was a problem with the driver
if you are having no issues @benjamin-rood, could you provide some examples?
@michaeldgraham this is a pretty valid use case, and so, do let us know as soon as it is fixed :smile:
Most helpful comment
This is a currently known issue that arose recently with such nested object returns of
@cypherfields, it's something I'm about to start working on in a few days - I'm sorry about the problem, it should be fixed up soon! 鉂わ笍