Skip to content

using Node.js driver - Server error: gremlin-javascript is not an available GremlinScriptEngine (599) #2

@mattwelke

Description

@mattwelke

I'm a MEAP reviewer. I'm following along and I'm on chapter 8 now, but by now I've decided to stop trying to create the Java app since I'm not very familiar with Java and struggled more with the details of setting up that app in IntelliJ IDEA than doing the actual programming. I decided to switch to Node.js since that's a daily driver language of mine. I've been able to get this working well so far, doing the less complex traversals in the book in my Node.js app. I had to dig through the Node.js library to learn that I had to import statics (conventionally imported as __ in the app itself) and use it for things like __.identity().

But, I ran into trouble with the second traversal in Chapter 8. My function looks like this. I use a similar approach to the example Java app that involves injecting the GraphTraversalSource object into the function:

const gremlin = require('gremlin');
const desc = gremlin.process.order.desc;
const __ = gremlin.process.statics;

async function getHighestRatedRestsNear(g, c, personId) {
    try {
        const rests = await g.V()
            .has('person', 'person_id', personId)
            .out('lives')
            .in_('within')
            .group()
            .by(__.identity())
            .by(__.in_('about').values('rating').mean())
            .unfold()
            .order()
            .by(__.values, desc)
            .limit(10)
            .project('restaurant_name', 'rating_average')
            .by(__.select(__.key).values('name'))
            .by(__.select(__.values))
            .toList();
        console.log(`Restaurants:`, rests);
    } catch (e) {
        console.log(`Error:`, e.message);
    }
    await c.close();
};

It results in the following console output:

Error: Server error: gremlin-javascript is not an available GremlinScriptEngine (599)

By commenting out bits of the traversal at a time, I determined that it works up until I add the .order().by(__.values, desc) part. This code:

const rests = await g.V()
    .has('person', 'person_id', personId)
    .out('lives')
    .in_('within')
    .group()
    .by(__.identity())
    .by(__.in_('about').values('rating').mean())
    .unfold().toList();
    // .order()
    // .by(__.values, desc)
    // .limit(10)
    // .project('restaurant_name', 'rating_average')
    // .by(__.select(__.key).values('name'))
    // .by(__.select(__.values))
    // .toList();

results in the following console output:

Restaurants: 
getHighestRatedRestsNear.js:24
Array(18) [Map(1), Map(1), Map(1), Map(1), Map(1), Map(1), Map(1), Map(1), …]

I googled the error message but wasn't able to find much. My guess so far is that it has to do with the setup of Gremlin Server according to the book not supporting the Node.js driver fully. Perhaps it only supports Groovy and Java as the book uses. What do you think about this? I don't mind following along only being able to run traversals in the Gremlin console, but I was finding it more interesting when I was able to follow along making an app I was able to understand well at the same time.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions