[ 
https://issues.apache.org/jira/browse/TINKERPOP-2184?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

stephen mallette closed TINKERPOP-2184.
---------------------------------------
    Resolution: Not A Problem

In the future, please use our [mailing 
list|https://groups.google.com/forum/#!forum/gremlin-users] or [stackoverflow 
|https://stackoverflow.com/questions/tagged/gremlin]for usage based questions. 

In answer to your question, I think that you just need to iterate your 
traversal discussed in a number of place but perhaps demonstrated best here:

http://tinkerpop.apache.org/docs/current/tutorials/the-gremlin-console/#result-iteration

When you do:

{code}
const names = await g.V()
{code}

names is just a {{Traversal}} instance not the result of that traversal. To get 
the result you need to iterate with something like {{toList()}} thus:

{code}
const names = await g.V().toList()
{code}

Note the discussion/examples related to "terminal steps" in the 
gremlin-javascript documentation:

http://tinkerpop.apache.org/docs/current/reference/#_connecting_4



> Difficulty connecting to Gremlin using the NodeJS implementation 
> -----------------------------------------------------------------
>
>                 Key: TINKERPOP-2184
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2184
>             Project: TinkerPop
>          Issue Type: Bug
>          Components: javascript
>    Affects Versions: 3.4.0
>            Reporter: Andric LibreSinn
>            Priority: Minor
>
> We are trying to use the fluent API because [within your 
> documentation|http://tinkerpop.apache.org/docs/current/reference/#_submitting_scripts_4]
>  you recommend not using script based requests.
> {noformat}
> TinkerPop does not recommend submitting script-based requests and generally 
> continues to support this feature for legacy reasons and corner use cases 
> which are still not completely addressed by the Gremlin language. Please 
> consider using bytecode-based requests instead when possible.{noformat}
> That being said I can't seem to connect or I am connecting but I cannot query 
> correctly. This is the current script-less code that I've put together.
>  
> {code:java}
> const gremlin = require('gremlin');
> const config = require('./config')
> const Graph = gremlin.structure.Graph
> const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection
> const PlainTextSaslAuthenticator = 
> gremlin.driver.auth.PlainTextSaslAuthenticator
> const username = `/dbs/${config.database}/colls/${config.collection}`
> const password = config.primaryKey
> const options = {
>   authenticator: new PlainTextSaslAuthenticator(username, password),
>   endpoint: config.endpoint,
>   traversalsource: 'g',
>   rejectUnauthorized: true,
>   mimeType: 'application/vnd.gremlin-v3.0+json',
> }
> const graph = new Graph()
> const connection = new DriverRemoteConnection(config.endpoint, options)
> const g = graph.traversal().withRemote(connection)
> const theWholePlate = async () => {
>   const names = await g.V('42f0da58-501b-4dfb-972d-abab025abdad')
>   console.log(names)
> }
> theWholePlate()
> {code}
> The output to `names` is
> {noformat}
> GraphTraversal {
>   graph: Graph {},
>   traversalStrategies: TraversalStrategies {
>     strategies: [[Object]]
>   },
>   bytecode: Bytecode {
>     sourceInstructions: [],
>     stepInstructions: [[Array]]
>   },
>   traversers: null,
>   sideEffects: null,
>   _traversalStrategiesPromise: null,
>   _traversersIteratorIndex: 0,
> }{noformat}
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to