neo4j-graphql-js icon indicating copy to clipboard operation
neo4j-graphql-js copied to clipboard

Can't return @cypher custom property when using generated mutations. Get Error Neo4jError: Expected parameter(s): cypherParams

Open CraigDeverall opened this issue 3 years ago • 5 comments

Replicated situation below:

Type Definition: type MyType { id: ID! name: string custom: @cypher(statement: """ """) }

Mutation Call: mutation ($id: ID!, $name: String! ) { UpdateMyType(id: $id, name: $name) { id name custom } }

Error: "Neo4jError: Expected parameter(s): cypherParams", "", " at captureStacktrace (node_modules/neo4j-driver/lib/result.js:275:15)", " at new Result (node_modules/neo4j-driver/lib/result.js:66:19)", " at newCompletedResult (node_modules/neo4j-driver/lib/transaction.js:446:10)", " at Object.run (node_modules/neo4j-driver/lib/transaction.js:285:14)", " at Transaction.run (node_modules/neo4j-driver/lib/transaction.js:121:32)", " at _callee2$ (node_modules/neo4j-graphql-js/dist/index.js:192:35)", " at tryCatch (node_modules/regenerator-runtime/runtime.js:63:40)", " at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:293:22)", " at Generator.next (node_modules/regenerator-runtime/runtime.js:118:21)", " at asyncGeneratorStep (node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js:5:24)"

Wasn't a critical issue to work around but it felt like a bug.

CraigDeverall avatar Mar 23 '21 23:03 CraigDeverall

I'm having the same error too.

Here is how I replicated the bug and the console outputs:

Query:

query {
   Content {
      title
      numberOfUpvotes
   }
}

console output:

neo4j-graphql-js MATCH (`content`:`Content`) RETURN `content` { .title ,numberOfUpvotes: apoc.cypher.runFirstColumn("MATCH (this)<-[uc:UPVOTED_CONTENT]-() RETURN COUNT(uc)", {this: content, cypherParams: $cypherParams}, false)} AS `content` +3m
neo4j-graphql-js {
   "offset": 0,
   "first": -1,
   "cypherParams": {
      "currentUser": null
   }
} +0ms

Notice that the second code block here contains "cypherParams".

Mutation:

mutation {
   UpdateContent(id:"aeba18b0-c0d4-4715-b701-eae7e4d4934e" title:"An interesting Title2") {
      title
      numberOfUpvotes
   }
}

console output:

neo4j-graphql-js MATCH (`content`:`Content`{id: $params.id}) SET `content` += {title:$params.title} RETURN `content` { .title ,numberOfUpvotes: apoc.cypher.runFirstColumn("MATCH (this)<-[uc:UPVOTED_CONTENT]-() RETURN COUNT(uc)", {this: content, cypherParams: $cypherParams}, false)} AS `content` +9m
neo4j-graphql-js {
   "params": {
      "id": "aeba18b0-c0d4-4715-b701-eae7e4d4934e",
      "title": "An interesting Title2"
   },
   "first": -1,
   "offset": 0
} +0ms

Notice that the second code block here doesn't contain "cypherParams". It may be why the cypher query that is run from the generated mutation returns this error.

maiieul avatar Apr 07 '21 10:04 maiieul

https://github.com/neo4j-graphql/neo4j-graphql-js/issues/608

michaeldgraham avatar May 02 '21 04:05 michaeldgraham

Replicated situation below:

Type Definition: type MyType { id: ID! name: string custom: @cypher(statement: """ """) }

Mutation Call: mutation ($id: ID!, $name: String! ) { UpdateMyType(id: $id, name: $name) { id name custom } }

Error: "Neo4jError: Expected parameter(s): cypherParams", "", " at captureStacktrace (node_modules/neo4j-driver/lib/result.js:275:15)", " at new Result (node_modules/neo4j-driver/lib/result.js:66:19)", " at newCompletedResult (node_modules/neo4j-driver/lib/transaction.js:446:10)", " at Object.run (node_modules/neo4j-driver/lib/transaction.js:285:14)", " at Transaction.run (node_modules/neo4j-driver/lib/transaction.js:121:32)", " at _callee2$ (node_modules/neo4j-graphql-js/dist/index.js:192:35)", " at tryCatch (node_modules/regenerator-runtime/runtime.js:63:40)", " at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:293:22)", " at Generator.next (node_modules/regenerator-runtime/runtime.js:118:21)", " at asyncGeneratorStep (node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js:5:24)"

Wasn't a critical issue to work around but it felt like a bug.

How did u manage to solve this. The cypher statement doesnt seem to need a param at all @CraigDeverall

teenkevo avatar Aug 29 '21 07:08 teenkevo

I'm sorry @teenkevo I couldn't say exactly. I believe it was worked around by simply not returning that custom cypher statement key. I highly recommend porting whatever you have to the now official version of this library though. https://neo4j.com/docs/graphql-manual/current/ https://www.npmjs.com/package/@neo4j/graphql

CraigDeverall avatar Aug 29 '21 19:08 CraigDeverall

Let me do just that, thanks. @CraigDeverall

teenkevo avatar Aug 30 '21 02:08 teenkevo