1

I am making graphql api server with tinkerpop3 graph database (aws neptune)
for example, I want implementation of graphql below

{
    post {
        id
        title,
        comments {
            id
        }
    }
}

and I make gremlin query like below

g.V().hasLabel('post').match(
    __.id().as('id'),
    __.values('title').as('title'),
    __.union(
        out('has_comment').match(
            __.id().as('id')
        ).select('id')
    ).fold().as('comments')
).select('id', 'title', 'comments')

but this query isn't working correctly. because id of comment is overlap with id of post.

I want use .as('id') locally in match statement. is there any solution?

4

1 回答 1

0

谢谢@jbmusso

我使用Map Scope.
修复了 gremlin 查询是打击,它是 GraphQL 的完美形式。不需要后期处理。

g.V().hasLabel('post').project('id', 'title', 'comments')
    .by(__.id())
    .by(__.values('title'))
    .by(__.out('has_comment').project('id')
        by(__.id()).fold()
    )
    .toList()
于 2018-01-25T04:54:41.440 回答