gremlin 局部变量是否匹配?

Is gremlin local variable in match?

我正在制作带有 tinkerpop3 图形数据库 (aws neptune) 的 graphql api 服务器
例如,我想在

下面实现 graphql
{
    post {
        id
        title,
        comments {
            id
        }
    }
}

然后我像下面这样进行 gremlin 查询

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')

但此查询无法正常工作。因为 id 的评论与 post 的 id 重叠。

我想在 match 语句中本地使用 .as('id')。 有解决办法吗?

谢谢@jbmusso

我使用 Map Scope.
解决了问题 修复了 gremlin 查询问题,它是 GraphQL 的完美形式。不需要 post 过程。

g.V().hasLabel('post').project('id', 'title', 'comments')
    .by(__.id())
    .by(__.values('title'))
    .by(__.out('has_comment').project('id')
        by(__.id()).fold()
    )
    .toList()