#!/usr/bin/perl

use strict;
use warnings;
use open ':std', ':encoding(UTF-8)';

use JSON::XS;
use FileHandle;

my $cqlFile = shift @ARGV || 'runController.cql';

my $cql;
my $fh = FileHandle->new( $cqlFile, 'r' );
read $fh, $cql, -s $fh;
$fh->close;

use REST::Neo4p;
eval {
    if ( REST::Neo4p->connect( "http://35.162.82.15:7474", "neo4j", "123123" ) ) {
        my $query = REST::Neo4p::Query->new($cql);
        $query->execute();
        my $result = $query->fetch->[0];
        my $json   = JSON::XS::encode_json($result);
        print "$json";
    }
};
if ($@) {
    print $@;
}
