[ https://issues.apache.org/jira/browse/TINKERPOP-2502?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17269667#comment-17269667 ]
Christopher Smith edited comment on TINKERPOP-2502 at 1/21/21, 10:00 PM: ------------------------------------------------------------------------- Internally, I don't especially care whether {{addV}} adds a "start step" or a "non-start step"; what I'm looking for is a consistent API so that I can write a single method that contains {{foo.addV().label('Stuff')...}} and initiate it consistently in either an anonymous or root context. With an anonymous traversal, I can say {{addStuff(__.start())}}, passing a {{GraphTraversal}} object, so we're good there. However, there's no way for me to get a plain/no-opped/whatever {{GraphTraversal}} out of {{GraphTraversalSource}}. The visible behavior is the same, and the method signatures are the same, but I can't abstract them together. With the acknowledgment that "in order to start the traversal, only {{V}}, {{E}}, {{addV}}, or {{addE}} make sense", I can also see an interface that exposes _only_ these "start methods"; it would be implemented by {{GraphTraversalSource}} (doing the bootstrapping), {{GraphTraversal}} (as a superinterface), and (indirectly?) the return value of something like {{__.start()}}. was (Author: chrylis): Internally, I don't especially care whether {{addV}} adds a "start step" or a "non-start step"; what I'm looking for is a consistent API so that I can write a single method that contains {{foo.addV().label('Stuff')...}} and initiate it consistently in either an anonymous or root context. With an anonymous traversal, I can say {{addStuff(__.start())}}, passing a {{GraphTraversal}} object, so we're good there. However, there's no way for me to get a plain/no-opped/whatever {{GraphTraversal}} out of {{GraphTraversalSource}}. The visible behavior is the same, and the method signatures are the same, but I can't abstract them together. > Consistent start API for anonymous and regular traversals > --------------------------------------------------------- > > Key: TINKERPOP-2502 > URL: https://issues.apache.org/jira/browse/TINKERPOP-2502 > Project: TinkerPop > Issue Type: Improvement > Components: process > Affects Versions: 3.4.9 > Reporter: Christopher Smith > Priority: Minor > > I am writing a graph-based application and am taking advantage of the > method-based nature of Gremlin to librarify some of my common usage patterns. > However, I'm encountering a frustrating problem where I frequently need to be > able to attach the same traversal steps to either a real > {{GraphTraversalSource}} or an anonymous traversal (usually for some nested > reason like a coalesced conditional insert). > The methods on {{__}} are mostly static, but I can call {{__.start()}} to > obtain a live {{GraphTraversal}} object and then proceed from there (invoking > {{GraphTraversal#addV}}, for example). {{GraphTraversalSource}}, however, > requires me to invoke the method {{GraphTraversalSource#addV}} to get > started, and there's no common base type. I think I could theoretically use > something like {{inject()}}, but that seems particularly odd. > It would be helpful to either have both {{GraphTraversal}} and > {{GraphTraversalSource}} implement a common interface holding the "start > opcodes" or to have a {{GraphTraversalSource#start()}} method that could be > used to obtain a "blank" traversal. -- This message was sent by Atlassian Jira (v8.3.4#803005)