const Graph = gremlin.structure.Graph;
const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;
const graph = new Graph();
const g = graph.traversal().withRemote(new DriverRemoteConnection('ws://localhost:8182/gremlin'));
Note that withRemote() method requires a RemoteConnection implementation, that is DriverRemoteConnection.
With the current version (3.3.2), there are two issues in JavaScript Gremlin that will make getting started a little more difficult. I will detail the issues and the workarounds here, but you should know that version TinkerPop 3.3.3 (available soon!) contains fixes for these issues:
First issue:
The DriverRemoteConnection class is not exported due to a bug in the implementation as detailed in the ticket TINKERPOP-1944, that is going to be fixed in the upcoming version of the GLV. In the meantime, you can import the DriverRemoteConnection class by using:
const DriverRemoteConnection = require('./node_modules/gremlin/lib/driver/driver-remote-connection');
Second issue:
GraphSON3, which is the default serialization format in Gremlin Server 3.3+, is not yet supported in Gremlin-JavaScript. We are planning to support it in the upcoming versions. In the meantime, if you want to use Gremlin-JavaScript against the Gremlin Server 3.3 you must include the GraphSON2 serializer.
In the server yaml configuration file, add the following line under serializers:
- { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV2d0] }}
Hope it helps,
Jorge