Adding, deleting, updating vertices is fine but when attempting to add edges I get the following exception stating edge additions not supported. Can anyone advise how to add edges when using remote client? Thanks in advance.
java.lang.IllegalStateException: Edge additions not supported at org.apache.tinkerpop.gremlin.structure.Vertex$Exceptions.edgeAdditionsNotSupported(Vertex.java:175) at org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex.addEdge(ReferenceVertex.java:47)
Link to code: https://gist.github.com/ptclarke/45472fa5c268a6e8441e4c35615194aa
The Vertex
object returned from a remote request is detached from the graph and is immutable so if you try to do this:
Vertex v = g.V(id).next()
v.addEdge(...)
it will fail as you are trying to add edges to an immutable object that has no connection to the remote graph. You should use Gremlin to add your edges and not operate on the returned objects directly:
g.V(id).addE(...).to(...)