Skip to content

Latest commit

 

History

History
50 lines (46 loc) · 1.71 KB

README.md

File metadata and controls

50 lines (46 loc) · 1.71 KB
Will be using this as the base template for integrating Neo4j, Gatsby and GraphQL -

Finds a route between two points of interest - see Neo4j Shortest Path

match (p1:PointOfInterest {name: "Central Park Tennis Center"})
match (p2:PointOfInterest {name: "The Pond"})
match sp=shortestPath((p1)-[:ROUTE*..200]-(p2))
unwind nodes(sp) as node
return {latitude: node.location.latitude, longitude: node.location.longitude}

Note that above query might not be the actual shortest distance between two points. It brings back shortest numbers of relationships. You might want use other Graph Data Science alogs for shortest weighted path.

To run

  • need to get access to neo4j sandbox for OSM data.
  • Add your neo4j sandbox bolt url and credentials to neo4j-graphql directory's .env file
  • run npm i in both the root gatsby-project and neo4j-grpahql directories
  • cd to neo4j-grpahqlstart neo4j backed graphql server (Apollo) and run npm start
  • cd .. and run gatsby develop
  • Example graphql query:
{
  PointOfInterest(first: 1) {
    name
    node_osm_id
    location {
      latitude
      longitude
    }
    routeToPOI(poi: "246164695") {
      latitude
      longitude
    }
    node_osm_id
    location {
      longitude
      latitude
    }
  }
}