neo4j-graphql / neo4j-graphql-js

NOTE: This project is no longer actively maintained. Please consider using the official Neo4j GraphQL Library (linked in README).
Other
608 stars 147 forks source link

DateTime filter passes Neo4j Integer instead of JavaScript Number #329

Open johnymontana opened 5 years ago

johnymontana commented 5 years ago

From @mneedham

Mark Needham new one. I have this query:

query {
  Run( first: 10, orderBy:  distance10kmMovingTime_asc, filter: {startDate:{year:2018    }}) {
    startDate {
      formatted
    }
    name
    _id
    distance
    prettyMovingTime
    prettyElapsedTime
    pacePerKm
    maximumSpeed
    distance10kmPrettyMovingTime
    distance10kmMovingTime
  }
}

where startDate is of type DateTime

that query translates to:

MATCH (`run`:`Run`) WHERE ((`run`.startDate = datetime($filter.startDate))) RETURN `run` {startDate: { formatted: toString(`run`.startDate) }, .name ,_id: ID(`run`), .distance ,prettyMovingTime: apoc.cypher.runFirstColumn("RETURN apoc.date.format(this.movingTime.milliseconds, 'ms', 'HH:mm:ss')", {this: run}, false),prettyElapsedTime: apoc.cypher.runFirstColumn("RETURN apoc.date.format(this.elapsedTime.milliseconds, 'ms', 'HH:mm:ss')", {this: run}, false),pacePerKm: apoc.cypher.runFirstColumn("WITH duration({seconds: this.movingTime.seconds / this.distance * 1000}) AS pace RETURN apoc.date.format(pace.milliseconds, 'ms', 'mm:ss')", {this: run}, false), .maximumSpeed ,distance10kmPrettyMovingTime: apoc.cypher.runFirstColumn("MATCH (this)-[:DISTANCE_EFFORT]->(effort)-[:DISTANCE]->(distance:Distance {name: '10k'}) RETURN apoc.date.format(effort.movingTime.milliseconds, 'ms', 'HH:mm:ss')", {this: run}, false),distance10kmMovingTime: apoc.cypher.runFirstColumn("MATCH (this)-[:DISTANCE_EFFORT]->(effort)-[:DISTANCE]->(distance:Distance {name: '10k'}) RETURN effort.movingTime.seconds", {this: run}, false)} AS `run` ORDER BY run.distance10kmMovingTime ASC  LIMIT $first
{
  "offset": 0,
  "first": 10,
  "filter": {
    "startDate": {
      "year": {
        "low": 2018,
        "high": 0
      }
    }
  }
}

which doesn't work, because of how the year value is represented in js land

William Lyon oh becuase it’s passing a Neo4j integer but it should be a javascript number?

michaeldgraham commented 3 years ago

https://github.com/neo4j-graphql/neo4j-graphql-js/issues/608