Github user barakyo commented on the issue:

    https://github.com/apache/tinkerpop/pull/938
  
    @spmallette the Elixir driver was modeled closely after the gremlin-python 
driver. A call to 
[Gremlex.Graph.g()](https://github.com/Revmaker/gremlex/blob/master/lib/gremlex/graph.ex#L30-L31)
 create an [Erlang Queue](http://erlang.org/doc/man/queue.html). This basically 
starts the queue and from there we build queries using the rest of the 
functions. Each function accepts the queue as its first argument and updates 
the queue by appending a tuple where the first value in the tuple is the 
function name and the second is its arguments. We then return the queue back to 
the user to allow them to continue to build the query. In case you aren't 
familiar with Elixir, the pipe operator (`|>`) allows the nice syntax of being 
able to pass the output from one function to the next. This allowed us to 
easily build queries and unit test our [query 
builder](https://github.com/Revmaker/gremlex/blob/master/test/graph_test.exs#L16-L18).
    
    An Erlang queue is represented by a tuple with two lists (front and back), 
so an empty queue would look like:
    
    ```Elixir
    iex(1)> Graph.g()
    {[], []}
    ```
    Calling a function simply appends a tuple to the queue with its arguments:
    
    ```
    iex(2)> Graph.g() |> Graph.v()
    {[{"V", []}], []}
    ```
    
    Once you've built you're query, we pass the structure to our Client module 
which in turn compiles the data structure to a query using 
[Graph.encode/1](https://github.com/Revmaker/gremlex/blob/master/lib/gremlex/graph.ex#L335-L366).
 Once the query is compiled, we construct a 
[request](https://github.com/Revmaker/gremlex/blob/master/lib/gremlex/request.ex#L15)
 to make to the server.
    
    You can see how we compile a query in our 
[tests](https://github.com/Revmaker/gremlex/blob/master/test/graph_test.exs#L393-L402).
 Here is a simple example:
    
    ```Elixir
    iex(4)> Graph.g() |> Graph.v() |> Graph.encode
    "g.V()"
    ```
    
    



---

Reply via email to