Closed johnymontana closed 5 years ago
Note that when GraphQL variables are not used the value is inlined in the generated cypher query:
{
PointOfInterest(poi_id: "Old Ship Saloon37.7977871-122.4007139") {
name
route: shortestPathRouteToPOI(poi_id: "Gestalt37.7647122-122.4233225") {
lat
lon
}
}
}
MATCH (pointOfInterest:PointOfInterest {poi_id:$poi_id}) RETURN pointOfInterest { .name ,shortestPathRouteToPOI: [ pointOfInterest_shortestPathRouteToPOI IN apoc.cypher.runFirstColumn("MATCH (b:PointOfInterest) WHERE b.poi_id = $poi_id
MATCH p=shortestPath((this)-[:ROUTE*..200]-(b))
UNWIND nodes(p) AS n
RETURN {lon: n.location.longitude, lat: n.location.latitude} AS route", {this: pointOfInterest, poi_id: "Gestalt37.7647122-122.4233225"}, true) | pointOfInterest_shortestPathRouteToPOI { .lat , .lon }] } AS pointOfInterest SKIP $offset
{ offset: 0,
first: -1,
poi_id: 'Old Ship Saloon37.7977871-122.4007139',
'1_poi_id': 'Gestalt37.7647122-122.4233225' }
After #200 the generated Cypher query and parameters are:
MATCH (`pointOfInterest`:`PointOfInterest` {poi_id:$poi_id}) RETURN `pointOfInterest` { .name ,shortestPathRouteToPOI: [ pointOfInterest_shortestPathRouteToPOI IN apoc.cypher.runFirstColumn("MATCH (b:PointOfInterest) WHERE b.poi_id = $end_poi_id
MATCH p=shortestPath((this)-[:ROUTE*..200]-(b))
UNWIND nodes(p) AS n
RETURN {lon: n.location.longitude, lat: n.location.latitude} AS route", {this: pointOfInterest, end_poi_id: "Gestalt37.7647122-122.4233225"}, true) | pointOfInterest_shortestPathRouteToPOI { .lat , .lon }] } AS `pointOfInterest` SKIP $offset
{ offset: 0,
first: -1,
poi_id: 'Old Ship Saloon37.7977871-122.4007139',
'1_end_poi_id': 'Gestalt37.7647122-122.4233225' }
which fixes the issue of not passing the end_poi_id
parameter value to the subquery in apoc.cypher.runFirstColumn
, however the value is inlined to the subquery for end_poi_id
. To be consistent with parameterization we should make use of the Cypher param 1_end_poi_id
instead:
{this: pointOfInterest, end_poi_id: $1_end_poi_id},
Seems like there is still an issue when a GraphQL variable is used for a field within an object passed as a parameter.
Schema:
input BInput {
param: String
}
type A {
b(bInput: BInput): String
@cypher(statement: "RETURN $bInput.param;")
}
Query:
query(var: String) {
A {
b(bInput: {param: $var})
}
}
Variables: {"var": "VALUE"}
In the generated Cypher parameters, 1_bInput
is { param: undefined }
instead of { param: 'VALUE' }
.
Fixed in #213
GraphQL schema:
GraphQL query:
GraphQL variables:
generated cypher query:
genereated cypher parameters:
Expected value of
1_end_poi_id
to beGestalt37.7647122-122.4233225
and notundefined
.