This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// clean up | |
CALL apoc.periodic.iterate( | |
"MATCH (n) RETURN n", | |
"DETACH DELETE n", | |
{ batchSize: 10000, parallel: true }); | |
// generate Entities | |
CALL apoc.generate.er(500000, 5000000, 'Client', 'TRANSFER_TO'); | |
// select ATMs | |
MATCH (c:Client) | |
WITH c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query { | |
FlightsSearchObjects(from: "Bangkok", to: "Moscow", date:"20200101") { | |
flights { | |
flight { | |
flight_number | |
price | |
duration | |
departs_local | |
arrival_local | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const pad = (s) => { | |
let str = s + ""; | |
while (str.length < 2) | |
str = "0" + str; | |
return str; | |
} | |
const flightsDateTime = new GraphQLScalarType({ | |
name: 'FlightsDateTime', | |
description: 'Description of flights dateTime type', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Query { | |
FlightsSearchObjects(from: String, to: String, date: String): [FlightsSearchResult] | |
} | |
const query = "CALL custom.getFlightsObjects($from, $to, $date, 2, 6) YIELD result RETURN result"; | |
export const resolvers = { | |
Query: { | |
FlightsSearchObjects : async (object, params, ctx, resolveInfo) => { | |
var result; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type FlightDetails { | |
flight_number: String! | |
duration: String! | |
price: FlightsInt! | |
departs_local: FlightsDateTime! | |
arrival_local: FlightsDateTime! | |
} | |
type FlightInfo { | |
flight: FlightDetails @neo4j_ignore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MATCH (a:Airport) WHERE this.city = a.city AND this <> a RETURN a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Airport { | |
code: String! | |
name: String! | |
country: String! | |
city: String! | |
location: Point! | |
directs: [Airport] @relation(name: "FLIES_TO", direction: "OUT") | |
neighbors: [Airport] @cypher(statement: "MATCH (a:Airport) WHERE this.city = a.city AND this <> a RETURN a") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const GET_AIRPORTS = gql` | |
query airportsPaginateQuery( | |
$first: Int | |
$offset: Int | |
$orderBy: [_AirportOrdering] | |
$filter: _AirportFilter | |
) { | |
Airport( | |
first: $first | |
offset: $offset |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Query | |
query={gql` | |
query airportsPaginateQuery( | |
$first: Int | |
$offset: Int | |
$orderBy: [_AirportOrdering] | |
$filter: _AirportFilter | |
) { | |
Airport( | |
first: $first |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CALL apoc.custom.asProcedure("getFlights", | |
"WITH { a: $a, b: $b, date: $date, tmin: $tmin, tmax: $tmax } as params | |
MATCH (a:Airport { city: params.a }) | |
WITH params, AVG(a.location.latitude) as ala, AVG(a.location.longitude) as alo | |
MATCH (b:Airport { city: params.b }) | |
WITH params, ala, alo, AVG(b.location.latitude) as bla, AVG(b.location.longitude) as blo | |
WITH params, distance(point({ latitude: ala, longitude: alo }), point({ latitude: bla, longitude: blo })) / 1000 * 1.05 as max | |
MATCH path = ((a:Airport { city: params.a })-[:FLIES_TO*..3]->(b:Airport { city: params.b })) | |
WHERE apoc.coll.sum([x IN relationships(path) | x.distance ]) <= max AND SIZE(apoc.coll.duplicates([ x IN nodes(path) | x.city ])) = 0 | |
WITH nodes(path) as routes, params |