themetalfleece / neogma

Object-Graph-Mapping neo4j framework, Fully-typed with TypeScript, for easy and flexible node and relationship operations
https://themetalfleece.github.io/neogma/
MIT License
124 stars 12 forks source link

relateTo requires relationship properties while createOne does not #87

Closed Ansis100 closed 10 months ago

Ansis100 commented 10 months ago

When calling relateTo (either the static, or the instance method) without specifying the relationship properties, it will crash with the following error:

Neo4jError: Expected parameter(s): propertyName

    at captureStacktrace (/project/node_modules/neo4j-driver-core/lib/result.js:611:17)
    at new Result (/project/node_modules/neo4j-driver-core/lib/result.js:105:23)
    at Session._run (/project/node_modules/neo4j-driver-core/lib/session.js:230:16)
    at Session.run (/project/node_modules/neo4j-driver-core/lib/session.js:180:27)
    at /project/node_modules/neogma/src/Queries/QueryRunner/QueryRunner.ts:304:24
    at getRunnable (/project/node_modules/neogma/src/Sessions/Sessions.ts:70:12)
    at QueryRunner.run (/project/node_modules/neogma/src/Queries/QueryRunner/QueryRunner.ts:283:23)
    at /project/node_modules/neogma/src/Queries/QueryBuilder/QueryBuilder.ts:819:28
    at getSession (/project/node_modules/neogma/src/Sessions/Sessions.ts:21:26)
    at getRunnable (/project/node_modules/neogma/src/Sessions/Sessions.ts:72:20) {
  constructor: [Function: Neo4jError] { isRetriable: [Function (anonymous)] },
  code: 'Neo.ClientError.Statement.ParameterMissing',
  retriable: false
}

However, creating an object and a relationship in the same createOne call will not have that error. The relationship property can be specified, but it's not required.

themetalfleece commented 10 months ago

Thanks for reporting it. There was a bug with the code which created the relationship properties object. It should be fixed at neogma version v1.13.0 that was just published. Please let me know if your issue is resolved.

As a side effect, the behavior of required changed - as now it's the correct one. In the past it would crash when "required" wasn't defined at the schema, however now it doesn't. To avoid surprises, I've made the required schema property non-optional, so it has to be explicitly defined.