是匹配的格雷姆林局部变量



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

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

我像下面这样进行小鬼查询

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评论与帖子id重叠。

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

谢谢你@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()

最新更新