【问题标题】:AND is not returning result in GraphQLAND 没有在 GraphQL 中返回结果
【发布时间】:2021-06-04 18:25:56
【问题描述】:

我正在尝试使用 AND 运算符编写查询以从 GraphQL 中的 neo4j 中提取数据,但它不返回任何结果。我正在使用 neo4j-graphql-js 库。我有以下架构

type Order {
    label: String
    id: String
    details: [OrderDetails] @relation(name: "RELATED_TO", direction: "OUT")
}

type OrderDetails {
    createdBy: String
    label: String
    oId: String
}

以下是查询:

{
  Order(filter: { AND: [{ label: "fruits", details: {label: "banana"} }] }) {
    label
  }
}

我也试过这个:

{
  Order(filter: {  label: "fruits", details: {label: "banana"}  }) {
    label
  }
}

但是这两个查询没有返回任何结果。 如果我只写 label: "fruits" 而没有 AND 它会返回结果,但我想要所有特别适合香蕉的水果订单。 有什么建议我哪里出错了吗?

【问题讨论】:

  • 我认为您可以将过滤分成两部分,1)水果,然后是香蕉。
  • 不,这没有帮助。该查询返回条件不符合香蕉的空行。

标签: graphql graphql-js grandstack neo4j-graphql-js


【解决方案1】:

既然您提到了使用 neo4j-graphql-js 库。你可以这样做:

{
  Order(
    filter: { label: "fruits", details_single: { label: "banana" } }
  ) {
    details {
      label
    }
  }
}

【讨论】:

    猜你喜欢
    • 2018-08-16
    • 2019-02-13
    • 2018-10-08
    • 2017-07-07
    • 2019-07-09
    • 1970-01-01
    • 2023-04-08
    • 2020-10-23
    • 1970-01-01
    相关资源
    最近更新 更多