cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

I am getting this error from my graphql query - Double(6.695317e+04) (of class org.neo4j.values.stor

jcct100
Node Clone

Hi there, 

I have added a @cypher directive to my GraphQL Type - getDistances.

I am getting an error returned from my graphQL query when I make a query using getDistances. Can you please tell me what might be causing the problem ? 

 

 

const typeDefs = gql`
    type Company {
        id: Int
        postCode: String
        name: String
        ratingValue: String
        structuralScore: String
        location: Point
        localAuthority: String
        isHospitality: Boolean
        hygieneScore: String
        confidenceInManagementScore: String
        businessType: String
        addressLineOne: String
        addressLineTwo: String
        addressLineThree: String
        addressLineFour: String
        getDistances(startLat: Float, startLng: Float, endLat: Float, endLng: Float): [Company]
            @cypher(
                statement: """
                WITH
                point({longitude: $startLng, latitude: $startLat, height: 100}) AS p1,
                point({latitude: $endLat, longitude: $endLng, height: 100}) AS p2
                RETURN point.distance(p1, p2) AS dist
                """)
    }
`;

 

 

GraphQL query 

 

 

{
  companies {
   getDistances(startLat: 51.400616, startLng: -0.2645342, endLat: 51.6443052331424, endLng: 0.61920005649669) {
    name 
}   
  }
}

 

 

Error response

 

 

{
  "errors": [
    {
      "message": "Double(6.695317e+04) (of class org.neo4j.values.storable.DoubleValue)",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "companies"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "code": "Neo.DatabaseError.Statement.ExecutionFailed",
          "name": "Neo4jError",
          "retriable": false,
          "stacktrace": [
            "Neo4jError: Double(6.695317e+04) (of class org.neo4j.values.storable.DoubleValue)",
            "",
            "    at captureStacktrace (/Users/james/development/graphql_server/node_modules/neo4j-driver-core/lib/result.js:611:17)",
            "    at new Result (/Users/james/development/graphql_server/node_modules/neo4j-driver-core/lib/result.js:105:23)",
            "    at newCompletedResult (/Users/james/development/graphql_server/node_modules/neo4j-driver-core/lib/transaction.js:502:12)",
            "    at Object.run (/Users/james/development/graphql_server/node_modules/neo4j-driver-core/lib/transaction.js:334:20)",
            "    at Transaction.run (/Users/james/development/graphql_server/node_modules/neo4j-driver-core/lib/transaction.js:175:34)",
            "    at Executor.transactionRun (/Users/james/development/graphql_server/node_modules/@neo4j/graphql/dist/classes/Executor.js:138:28)",
            "    at /Users/james/development/graphql_server/node_modules/@neo4j/graphql/dist/classes/Executor.js:126:25",
            "    at TransactionExecutor._safeExecuteTransactionWork (/Users/james/development/graphql_server/node_modules/neo4j-driver-core/lib/internal/transaction-executor.js:141:26)",
            "    at TransactionExecutor.<anonymous> (/Users/james/development/graphql_server/node_modules/neo4j-driver-core/lib/internal/transaction-executor.js:128:46)",
            "    at step (/Users/james/development/graphql_server/node_modules/neo4j-driver-core/lib/internal/transaction-executor.js:52:23)"
          ]
        }
      }
    }
  ],
  "data": null
}

 

 

 

1 REPLY 1

You're getting that error because the statement you have provided to the cypher directive returns a Float type. However, your type definitions expect a list of Company objects. The following type definition should work for you:

    type Company {
        id: Int
        postCode: String
        name: String
        ratingValue: String
        structuralScore: String
        location: Point
        localAuthority: String
        isHospitality: Boolean
        hygieneScore: String
        confidenceInManagementScore: String
        businessType: String
        addressLineOne: String
        addressLineTwo: String
        addressLineThree: String
        addressLineFour: String
        getDistances(startLat: Float, startLng: Float, endLat: Float, endLng: Float): Float
            @cypher(
                statement: """
                WITH
                point({longitude: $startLng, latitude: $startLat, height: 100}) AS p1,
                point({latitude: $endLat, longitude: $endLng, height: 100}) AS p2
                RETURN point.distance(p1, p2) AS dist
                """
            )
    }