This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git


The following commit(s) were added to refs/heads/master by this push:
     new 5735712ff0 Expand the From Step reference section
5735712ff0 is described below

commit 5735712ff03647ef2d101e87be8786d0519d89b8
Author: Stephen Mallette <[email protected]>
AuthorDate: Thu Sep 10 17:57:06 2026 +0000

    Expand the From Step reference section
    
    The From Step section was a bare stub with no runnable examples and no
    prose on the semantics of from()'s argument forms. Add a description of
    the three argument forms (from(String), from(Traversal), from(Vertex)),
    a sentence on the symmetric from()/to() pairing, and two runnable
    examples against the modern graph: an addE().from('a') edge creation and
    a path().from('a').to('b') sub-path selection.
    
    Assisted-by: Kiro:claude-opus-4.8
---
 docs/src/reference/the-traversal.asciidoc | 32 ++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/docs/src/reference/the-traversal.asciidoc 
b/docs/src/reference/the-traversal.asciidoc
index 40c45c58e1..92802edd52 100644
--- a/docs/src/reference/the-traversal.asciidoc
+++ b/docs/src/reference/the-traversal.asciidoc
@@ -2319,11 +2319,41 @@ 
link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gre
 
 The `from()`-step is not an actual step, but instead is a "step-modulator" 
similar to <<as-step,`as()`>> and
 <<by-step,`by()`>>. If a step is able to accept traversals or strings then 
`from()` is the
-means by which they are added. The general pattern is `step().from()`. See 
<<to-step,`to()`>>-step.
+means by which they are added. The general pattern is `step().from()`.
+
+Depending on the step being modulated, `from()` designates a "source" element 
-- the out-vertex of a new
+edge for <<addedge-step,`addE()`>>, or the lower bound of the sub-path 
selected by <<path-step,`path()`>>,
+<<simplepath-step,`simplePath()`>>, and <<cyclicpath-step,`cyclicPath()`>>. It 
accepts three forms of argument:
+
+* `from(String)` -- a step-label previously assigned with <<as-step,`as()`>>; 
the element labeled by that
+`as()` becomes the source.
+* `from(Traversal)` -- a child traversal whose result is used as the source 
element.
+* `from(Vertex)` -- an explicit `Vertex` object, a convenience offered by the 
language variants (which
+resolve the `Vertex` down to its id) rather than a canonical Gremlin argument 
form.
+
+`from()` is the symmetric counterpart of <<to-step,`to()`>>: on `addE()` the 
two modulators designate the
+edge's source (out) and target (in) vertices, while on `path()`, 
`simplePath()`, and `cyclicPath()` they
+bound the range of the path by naming its start and end elements.
 
 The list of steps that support `from()`-modulation are: 
<<simplepath-step,`simplePath()`>>, <<cyclicpath-step,`cyclicPath()`>>,
  <<path-step,`path()`>>, and <<addedge-step,`addE()`>>.
 
+[gremlin-groovy,modern]
+----
+g.V().has('name','marko').as('a').
+      out('created').
+      addE('createdBy').from('a') <1>
+g.V().has('name','vadas').as('a').
+      in('knows').as('b').
+      out('knows').where(neq('a')).
+      path().from('a').to('b').by('name') <2>
+----
+
+<1> `from('a')` names the marko-vertex (labeled by `as('a')`) as the new 
edge's source, while the incoming
+traverser (lop, the created software) supplies the target -- producing a 
`createdBy` edge from marko to lop.
+<2> The full path runs from vadas to marko to josh; `from('a')` and `to('b')` 
bound it to the sub-path
+between the vadas- and marko-vertices.
+
 [NOTE, caption=Javascript]
 ====
 The term `from` is a reserved word in Javascript, and therefore must be 
referred to in Gremlin with `from_()`.

Reply via email to