Gremlin-Server client with ad-hoc extensible, reactive, typeclass based API allowing for using turing complete graph traversal language gremlin to query graph databases from browser
Scala
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
js/src
project
.gitignore
README.md

README.md

#scalajs-gremlin-client

Allows your browser applications to communicate with Gremlin Server via reactive-websocket thanks to Monifu and uPickle.

  • dependency : "com.viagraphs" %%% "scalajs-gremlin-client" % "0.0.3-SNAPSHOT"
  • Scala.js version : 0.6.5

Mainly it approaches :

  • gremlin's turing completeness by letting its users deal with it themselves in their application, thanks to Scala's Type Classes and excellent serialization library uPickle. Any new type of response might be added by user himself in his application by adding an evidence for a Reader type class like this. Found a new kind of response/request? Add it to your app and submit a feature request :-)
  • gremlin server response streaming which is handled the Rx way thanks to the awesome Monifu project

##Testing

This expects gremlin-sever be already running, please see sbt settings :

> js/fastOptStage::test

This starts gremlin-server before running a test suite if you have gremlinServerHome set up correctly :

> js/test

##Usage

// requests are built using js.Dynamic literals 
lit(
  EvalOp,
  DefaultProc,
  Args(
    lit(
      GremlinArg("g.v(1)"),
      BatchSizeArg(20),
      LangArg("gremlin-groovy")
    )
  )
)

// import all types or just those that you'll need
 import com.viagraphs.gremlin.client._

// connect to server
val client = GremlinClient(Url(WS, "localhost", 8182, Option.empty))

// sending a request requires specifying return type information to satisfy uPickle's Reader TypeClass. 
// You'll get strongly typed result in return...
val observable = client.send[Vector[Vertex]](query)

// do all kinds of Rx operations 
observable.map(...).filter(...).foreach(...) 
  • Observable contains only responses corresponding to particular requestId, so you don't need to worry about that
  • Please see GremlinClientSuite as a source of inspiration
  • As gremlin language is turing complete, it is inevitable that you'll find new and new return types that are not supported. In that case you need to add corresponding uPickle Reader to Implicits

###NOTE :

  • Just the basic operations are implemented and tested so far - but it is expected that adding new operations will mostly consist in adding a TypeClass evidence
  • Tests work on real operating systems only, some additional work required on MS Windows
  • Requires java 8, as gremlin-server does