I am using the gremlin plugin for nodejs, communicating to gremlin server with an embedded neo4j graph. I am able to query and create vertices, but unable to create any edges due to an error "Could not locate method: DefaultGraphTraversal.to." Any ideas??
I am able to create vertices and edges using the gremlin console connecting to the same gremlin server as the nodejs program.
Gremlin console & server 3.4.1 Gremlin NodeJS npm 3.4.1 Tinkerpop Neo4J-gremlin plugin: 3.4.1
const gremlin = require('gremlin');
const traversal = gremlin.process.AnonymousTraversalSource.traversal;
const Graph = gremlin.structure.Graph;
const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;
const g = traversal().withRemote(new DriverRemoteConnection('ws://localhost:8182/gremlin'));
async function run(){
const phil = await g.V().has('name', 'phil').next();
console.log("Have Phil: " +JSON.stringify(phil ));
g.V().has('name', 'stephen').next()
.then(stephen => {
console.log("Have Steve: " +JSON.stringify(stephen));
const e1 = g.V(phil).addE('friends').to(stephen).next();
console.log(e1);
})
.catch(err => console.log(err));
}
run();
Below is the output. As you can see, I am able to fetch the vertices fine, but receive this error during the edge creation.
Have Phil: {"value":{"id":18,"label":"person"},"done":false}
gremlin.js:13
Have Steve: {"value":{"id":7,"label":"person"},"done":false}
gremlin.js:17
Promise { pending }
gremlin.js:19
(node:48830) UnhandledPromiseRejectionWarning: Error: Server error: Could not locate method: DefaultGraphTraversal.to([{value={id=7, label=person}, done=false}]) (599)
at Connection._handleMessage (/Users/byronbailey/OneDrive - Cargill Inc/VSC/GraphTest/node_modules/gremlin/lib/driver/connection.js:265:9)
at WebSocket._ws.on (/Users/byronbailey/OneDrive - Cargill Inc/VSC/GraphTest/node_modules/gremlin/lib/driver/connection.js:128:43)
at WebSocket.emit (events.js:189:13)
at Receiver._receiver.onmessage (/Users/byronbailey/OneDrive - Cargill Inc/VSC/GraphTest/node_modules/ws/lib/WebSocket.js:141:47)
at Receiver.dataMessage (/Users/byronbailey/OneDrive - Cargill Inc/VSC/GraphTest/node_modules/ws/lib/Receiver.js:380:14)
at Receiver.getData (/Users/byronbailey/OneDrive - Cargill Inc/VSC/GraphTest/node_modules/ws/lib/Receiver.js:330:12)
at Receiver.startLoop (/Users/byronbailey/OneDrive - Cargill Inc/VSC/GraphTest/node_modules/ws/lib/Receiver.js:165:16)
at Receiver.add (/Users/byronbailey/OneDrive - Cargill Inc/VSC/GraphTest/node_modules/ws/lib/Receiver.js:139:10)
at Socket._ultron.on (/Users/byronbailey/OneDrive - Cargill Inc/VSC/GraphTest/node_modules/ws/lib/WebSocket.js:138:22)
at Socket.emit (events.js:189:13)
warning.js:18
(node:48830) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
warning.js:18
(node:48830) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.