【问题标题】:Graphql throwing "The repeat()-traversal was not defined" on queryGraphql 在查询中抛出“未定义重复()遍历”
【发布时间】:2023-03-29 19:20:01
【问题描述】:

我正在使用 neptune 和 graphql,但出现此错误:

"Server error: {\"detailedMessage\":\"The repeat()-traversal was not defined: RepeatStep(until([NeptuneMemoryTrackerStep, NeptuneHasStep([~label.eq("sample"), ~key.eq(id)])]),emit(true))\",\"code\":\"InternalFailureException\",\"requestId\":\"<id>\"}

这是我的查询:

 g
.V(keyId)
.repeat(__.outE('RELATIONSHIP').inV())
.dedup()
.until(__.and(__.hasLabel('sample'),
__.hasKey('id')))
.emit()
.filter(__.label().is('sample'))
.dedup()
.values('id')
.toList();

如何正确重复此查询?

【问题讨论】:

    标签: graphql apollo react-apollo graphql-js amazon-neptune


    【解决方案1】:

    主要问题是重复的结束括号在错误的位置。它需要在dedup 之后和until 之前。由于您没有使用边缘属性,如果您愿意,可以将 outE().inV 替换为 out()。我对循环终止条件有点好奇,因为您似乎只想找到一个带有“样本”标签和一个名为“id”的属性的顶点,但您并不关心该属性的值。我也不确定您在查询中的filter。这确实复制了 until 中所做的事情,如果真的需要,可以写成 hasLabel('sample')

     g.V(keyId).
       repeat(__.outE('RELATIONSHIP').inV().dedup()).
       until(__.and(__.hasLabel('sample'), __.hasKey('id'))).emit().
      filter(__.label().is('sample')).
      dedup().
      values('id').
      toList();
    

    如果我上面写的任何内容没有意义,或者我遗漏了问题的某些方面,请添加评论,我会更新答案。

    【讨论】:

    • 感谢您的回复,我应该选择两个不同的名称,我将编辑和更新为“父”和“子”之类的名称。事实证明,这个问题是海王星更新的,不支持我实现其他东西的方式。不过这看起来更干净,所以我也要尝试使用它
    猜你喜欢
    • 2010-11-12
    • 2019-07-05
    • 2019-05-17
    • 2020-05-06
    • 2016-01-31
    • 2014-09-12
    • 2015-01-29
    • 2012-06-15
    相关资源
    最近更新 更多