Neo4j-graphql-js: Comma appended to subquery parameter object for Cypher directive scalar field results in Cypher syntax error

Created on 22 Feb 2019  路  4Comments  路  Source: neo4j-graphql/neo4j-graphql-js

With these type definitions:

totalSurface: Float 
  @cypher (
    statement: "MATCH (:Tract)<-[r:SURFACE_OWNERSHIP]-(this) return sum(r.net_surface_acres)"
  )
  totalMinerals: Float 
  @cypher (
    statement: "MATCH (:Tract)<-[r:MINERAL_OWNERSHIP]-(this) return sum(r.net_mineral_acres)"
  )

the generated Cypher query includes an extra comma at the end of the Cypher parameters object passed to apoc.cypher.runFirstColumn, resulting in a Cypher Syntax error:

MATCH (`owner`:`Owner` ) RETURN `owner` { .name ,totalSurface: apoc.cypher.runFirstColumn("MATCH (:Tract)<-[r:SURFACE_OWNERSHIP]-(this) return sum(r.net_surface_acres)", {this: owner, }, false),totalMinerals: apoc.cypher.runFirstColumn("MATCH (:Tract)<-[r:MINERAL_OWNERSHIP]-(this) return sum(r.net_mineral_acres)", {this: owner, }, false)} AS `owner` SKIP 0

{this: owner, } should be {this: owner}

This appears to have been introduced in v2.4.0

See discussion from Neo4j community forum.

All 4 comments

I'd like to add that this error occurred with every query in our schema that had the @cypher directive. Not a single one would work.

@MuddyBootsCode There should be a fix for this in v2.4.1. Could you give it a try and let us know if it resolves the problem?

Having faced the same situation, v2.4.1 does fix the issue for me. Cheers @johnymontana

@MuddyBootsCode and I are working on the same product. We are on 2.4.2 and I can confirm it is indeed working! Good stuff!

Was this page helpful?
0 / 5 - 0 ratings