-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathschema.graphql
53 lines (53 loc) · 1.5 KB
/
schema.graphql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
type Step @exclude {
latitude: Float
longitude: Float
}
type Tag @exclude {
key: String
value: String
}
type PointOfInterest @exclude(operations: [CREATE, UPDATE, DELETE]) {
name: String
location: Point
type: String
wikipedia: String
@cypher(
statement: """
MATCH (this)-->(t:OSMTags)
WHERE EXISTS(t.wikipedia) WITH t LIMIT 1
CALL apoc.load.json('https://en.wikipedia.org/w/api.php?action=parse&prop=text&formatversion=2&format=json&page=' + apoc.text.urlencode(t.wikipedia)) YIELD value
RETURN value.parse.text
"""
)
tags(limit: Int = 10): [Tag]
@cypher(
statement: """
MATCH (this)-->(t:OSMTags)
UNWIND keys(t)[0..$limit] AS key
RETURN {key: key, value: t[key]} AS tag
"""
)
routeToPOI(name: String!): [Step]
@cypher(
statement: """
MATCH (other:PointOfInterest {name: $name})
CALL gds.beta.shortestPath.dijkstra.stream({
nodeProjection: 'OSMNode',
relationshipProjection: {
ROUTE: {
type: 'ROUTE',
properties: 'distance',
orientation: 'UNDIRECTED'
}
},
sourceNode: id(this),
targetNode: id(other),
relationshipWeightProperty: 'distance'
})
YIELD nodeIds
WITH [nodeId IN nodeIds | gds.util.asNode(nodeId)] AS pathNodes
UNWIND pathNodes AS node
RETURN {latitude: node.location.latitude, longitude: node.location.longitude} AS route
"""
)
}