I was looking for the easiest way to execute a single gremlin query from the command line, and cobbled this together using the gremlin console:
To use:
docker-compose up
to fire up a local Tinkerpop./gremlin.query.sh host "query"
Example:
> ./gremlin-query.sh localhost "g.addV('foobar')"
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/path/to/apache-tinkerpop-gremlin-console-3.4.10/lib/groovy-2.5.14-indy.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Server: localhost
Query: g.addV('foobar')
Result:
result{object=v[0] class=org.apache.tinkerpop.gremlin.structure.util.reference.ReferenceVertex}
> ./gremlin-query.sh localhost "g.V().elementMap()"
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/path/to/apache-tinkerpop-gremlin-console-3.4.10/lib/groovy-2.5.14-indy.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Server: localhost
Query: g.V().elementMap()
Result:
result{object={id=0, label=foobar} class=java.util.LinkedHashMap}
>
It'll do for now, but I'd prefer:
- to get rid of those warnings
- more legible serialization of the result