Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

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

Open
CraigDeverall opened this issue Mar 23, 2021 · 5 comments

Comments

@CraigDeverall
Copy link

CraigDeverall commented Mar 23, 2021

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.

@maiieul
Copy link

maiieul commented Apr 7, 2021

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.

@michaeldgraham
Copy link
Collaborator

#608

@teenkevo
Copy link

teenkevo commented Aug 29, 2021

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

@CraigDeverall
Copy link
Author

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

@teenkevo
Copy link

Let me do just that, thanks. @CraigDeverall

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants