How to use the gremlin.driver function in gremlin

To help you get started, we’ve selected a few gremlin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws-samples / amazon-neptune-samples / gremlin / visjs-neptune / indexLambda.js View on Github external
exports.handler = function(event, context, callback) {

    var DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;
    var Graph = gremlin.structure.Graph;
    //Use wss:// for secure connections. See https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-ssl.html 
    dc = new DriverRemoteConnection('wss://'+process.env.NEPTUNE_CLUSTER_ENDPOINT+':'+process.env.NEPTUNE_PORT+'/gremlin');
    var graph = new Graph();
    var g = graph.traversal().withRemote(dc);

    const headers = {
        'Access-Control-Allow-Origin': '*',
        'Access-Control-Allow-Methods': 'OPTIONS, POST, GET',
        'Access-Control-Max-Age': 2592000, // 30 days
        /** add other headers as per requirement */
        'Access-Control-Allow-Headers' : '*',
        "Content-Type": "application/json"
    };

    console.log("Path Parameters => "+ event.pathParameters);
github Azure-Samples / azure-cosmos-db-graph-npm-bom-sample / webapp / dao / cosmosdb_dao.js View on Github external
this.cosmos_gremlin_uri    = process.env.AZURE_COSMOSDB_GRAPHDB_URI;    // https://cjoakimcosmosdbgremlin.documents.azure.com:443/
        this.cosmos_gremlin_wssuri = 'wss://' + this.cosmos_gremlin_acct + '.gremlin.cosmosdb.azure.com:443/gremlin';
        this.graph_coll_link       = '/dbs/' + this.cosmos_gremlin_db + '/colls/' + this.cosmos_gremlin_graph;

        console.log('cosmos_gremlin_acct:   ' + this.cosmos_gremlin_acct);
        console.log('cosmos_gremlin_db:     ' + this.cosmos_gremlin_db);
        console.log('cosmos_gremlin_graph:  ' + this.cosmos_gremlin_graph);
        console.log('cosmos_gremlin_views:  ' + this.cosmos_gremlin_views);
        console.log('cosmos_gremlin_wssuri: ' + this.cosmos_gremlin_wssuri);
        console.log('graph_coll_link:       ' + this.graph_coll_link); 

        // Gremlin client
        var guri  = this.cosmos_gremlin_wssuri;
        var gkey  = this.cosmos_gremlin_key
        var glink = this.graph_coll_link;
        var authenticator = new gremlin.driver.auth.PlainTextSaslAuthenticator(glink, gkey);
        this.gremlin_client = new gremlin.driver.Client(
            guri, 
            { 
                authenticator,
                traversalsource : "g",
                rejectUnauthorized : true,
                mimeType : "application/vnd.gremlin-v2.0+json"
            }
        );

        // SQL client
        var suri = this.cosmos_gremlin_uri; 
        var skey = this.cosmos_gremlin_key;
        this.sql_client = new CosmosClient({ endpoint: suri, auth: { masterKey: skey } });
    }
github Azure-Samples / azure-cosmos-db-graph-npm-bom-sample / webapp / dao / cosmosdb_dao.js View on Github external
this.cosmos_gremlin_wssuri = 'wss://' + this.cosmos_gremlin_acct + '.gremlin.cosmosdb.azure.com:443/gremlin';
        this.graph_coll_link       = '/dbs/' + this.cosmos_gremlin_db + '/colls/' + this.cosmos_gremlin_graph;

        console.log('cosmos_gremlin_acct:   ' + this.cosmos_gremlin_acct);
        console.log('cosmos_gremlin_db:     ' + this.cosmos_gremlin_db);
        console.log('cosmos_gremlin_graph:  ' + this.cosmos_gremlin_graph);
        console.log('cosmos_gremlin_views:  ' + this.cosmos_gremlin_views);
        console.log('cosmos_gremlin_wssuri: ' + this.cosmos_gremlin_wssuri);
        console.log('graph_coll_link:       ' + this.graph_coll_link); 

        // Gremlin client
        var guri  = this.cosmos_gremlin_wssuri;
        var gkey  = this.cosmos_gremlin_key
        var glink = this.graph_coll_link;
        var authenticator = new gremlin.driver.auth.PlainTextSaslAuthenticator(glink, gkey);
        this.gremlin_client = new gremlin.driver.Client(
            guri, 
            { 
                authenticator,
                traversalsource : "g",
                rejectUnauthorized : true,
                mimeType : "application/vnd.gremlin-v2.0+json"
            }
        );

        // SQL client
        var suri = this.cosmos_gremlin_uri; 
        var skey = this.cosmos_gremlin_key;
        this.sql_client = new CosmosClient({ endpoint: suri, auth: { masterKey: skey } });
    }
github oslabs-beta / mogwaijs / testData / app.js View on Github external
"use strict";

const Gremlin = require('gremlin');

const config = require("./config");
const cohort = require('./cohortMembers');
const groups = require('./seniorGroups');
const teams = require('./teammembers');

const authenticator = new Gremlin.driver.auth.PlainTextSaslAuthenticator(`/dbs/${config.database}/colls/${config.collection}`, config.primaryKey)

const client = new Gremlin.driver.Client(
    config.endpoint, 
    { 
        authenticator,
        traversalsource : "g",
        rejectUnauthorized : true,
        mimeType : "application/vnd.gremlin-v2.0+json"
    }
);


function dropGraph()
{
    console.log('Running Drop');
    return client.submit('g.V().outE().drop()', { })
        .then(()=> client.submit('g.V().drop()', { }))
        .then(function (result) {
github oslabs-beta / mogwaijs / testData / app.js View on Github external
"use strict";

const Gremlin = require('gremlin');

const config = require("./config");
const cohort = require('./cohortMembers');
const groups = require('./seniorGroups');
const teams = require('./teammembers');

const authenticator = new Gremlin.driver.auth.PlainTextSaslAuthenticator(`/dbs/${config.database}/colls/${config.collection}`, config.primaryKey)

const client = new Gremlin.driver.Client(
    config.endpoint, 
    { 
        authenticator,
        traversalsource : "g",
        rejectUnauthorized : true,
        mimeType : "application/vnd.gremlin-v2.0+json"
    }
);


function dropGraph()
{
    console.log('Running Drop');
    return client.submit('g.V().outE().drop()', { })
github Azure-Samples / azure-cosmos-db-graph-nodejs-getting-started / app.js View on Github external
"use strict";

const Gremlin = require('gremlin');
const config = require("./config");

const authenticator = new Gremlin.driver.auth.PlainTextSaslAuthenticator(`/dbs/${config.database}/colls/${config.collection}`, config.primaryKey)

const client = new Gremlin.driver.Client(
    config.endpoint, 
    { 
        authenticator,
        traversalsource : "g",
        rejectUnauthorized : true,
        mimeType : "application/vnd.gremlin-v2.0+json"
    }
);


function dropGraph()
{
    console.log('Running Drop');
    return client.submit('g.V().drop()', { }).then(function (result) {
github prabushitha / gremlin-visualizer / proxy-server.js View on Github external
app.post('/query', (req, res, next) => {
  const gremlinHost = req.body.host;
  const gremlinPort = req.body.port;
  const nodeLimit = req.body.nodeLimit;
  const query = req.body.query;

  const client = new gremlin.driver.Client(`ws://${gremlinHost}:${gremlinPort}/gremlin`, { traversalSource: 'g', mimeType: 'application/json' });

  client.submit(makeQuery(query, nodeLimit), {})
    .then((result) => res.send(nodesToJson(result._items)))
    .catch((err) => next(err));

});
github shutterstock / gremlin-aws-sigv4 / lib / driver / aws-sigv4-driver-remote-connection.js View on Github external
.then((result) => {
          delete this._rejections[queryId];
          resolve(new gremlin.driver.RemoteTraversal(result.toArray()));
        })
        .catch(reject);
github oslabs-beta / mogwaijs / functions / mogwai.js View on Github external
function localConnect(username, password, uri){
  const authenticator = new Gremlin.driver.auth.PlainTextSaslAuthenticator(`'${username}', '${password}'`)

  const client = new Gremlin.driver.Client(
    uri, 
    { 
        authenticator,
        traversalsource : "g",
        rejectUnauthorized : true,
        mimeType : "application/vnd.gremlin-v2.0+json"
    }
  );
  mogwai.client = client;
  return client;
}
github oslabs-beta / mogwaijs / functions / mogwai.js View on Github external
function remoteConnect(db, coll, primaryKey, uri){
    const authenticator = new Gremlin.driver.auth.PlainTextSaslAuthenticator(`/dbs/${db}/colls/${coll}`, primaryKey)

const client = new Gremlin.driver.Client(
    uri, 
    { 
        authenticator,
        traversalsource : "g",
        rejectUnauthorized : true,
        mimeType : "application/vnd.gremlin-v2.0+json"
    }
);
mogwai.client = client;
return client;
}