cancel
Showing results for 
Search instead for 
Did you mean: 

Type CartesianPoint : [GraphQL error]: Message: Cannot read property 'x' of undefined

jonasdumas
Node Link

Hello,
We would like to migrate from neo4j-graphql-js to Neo4j GraphQL Library.
We got an issue with CartesianPoint and can't find the solution.

Here's the problem. We've a custom resolver that return a Post object (which match our schema). Everything works except the field with CartesianPoint (from a nested object) who return this error:
[GraphQL error]: Message: Cannot read property 'x' of undefined,

In front it's fetched via GraphQL like this:

Post {
  CustomFieldContent {
   [...]
    value_spatial {
      x
      y
    }
  }
}

On backend, when we log our Post object we've a correct object for value_spatial. If no value, it's null. Else, when we got a value, we've tested 2 differents approach to define the object (both return the previous error) :

  1. Cusom => value_spatial: { x: 46.19863361913244, y: 6.140601539612646 }
  2. Cypher Point object => value_spatial: Point {
    srid: [Integer],
    x: 46.19863361913244,
    y: 6.140601539612646,
    z: undefined
    }

Here's our types:

  type  CustomFieldContent {
         [...]
        post: Post @cypher(statement: "MATCH (this)<-[:DEFINED_WITH]-(post) RETURN post"),
       value_spatial: CartesianPoint,
    }
  type Post {
         [...]
          customFieldContents: [CustomFieldContent] @cypher(statement: "MATCH (this)-[:DEFINED_WITH]->(cfc) RETURN cfc ORDER BY cfc.field_order")
 }

It seems the issue comes from the Neo4j GraphQL Library as the object we retrun thru the resolver is correct (and was working with neo4j-graphql-js).

FYI, we've also tested to replace custom @cypher statement with traditional @relationhship approach but it doesn't change the behaviour.

Any idea where is the problem?

Thank you

Jonas

1 ACCEPTED SOLUTION

jonasdumas
Node Link

Ok, we've found the solution by exploring Neo4j Graphql Library source code.
For anybody who got same problem, in order to make it work it's needed to include CartesianPoint value into a point object to be handled correctly by the library:

value_spatial: { 
    point {
       x: 46.19863361913244,
      y: 6.140601539612646,
     }
}

View solution in original post

1 REPLY 1

jonasdumas
Node Link

Ok, we've found the solution by exploring Neo4j Graphql Library source code.
For anybody who got same problem, in order to make it work it's needed to include CartesianPoint value into a point object to be handled correctly by the library:

value_spatial: { 
    point {
       x: 46.19863361913244,
      y: 6.140601539612646,
     }
}
Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.