排除数组关系为空的结果的 GraphQL 查询

GraphQL query that excludes results where an array relationship is empty

我有这个查询(在 Hasura 中以防万一):

query MyQuery {
  records(distinct_on:[recordId],   where: { modelId: {_eq: "2f1f70b8-cb7b-487c-9e4c-ca03624ce926"}}) {
    recordId
    inboundEdges(where: {fromModelId: {_eq: "f0e19461-6d38-4148-8041-54eba6451293"}}) {
      fromRecord {
        property_path_values(where:{stringValue:{_eq:"2021-08-26"}}) {
          stringValue
        }
      }
    }
  }
}

我得到了这个结果:

{
  "data": {
    "records": [
      {
        "recordId": "2fbe37b1-78db-4b22-b713-2388cfb52597",
        "inboundEdges": [
          {
            "fromRecord": {
              "property_path_values": [
                {
                  "stringValue": "2021-08-26"
                }
              ]
            }
          },
          {
            "fromRecord": {
              "property_path_values": [
                {
                  "stringValue": "2021-08-26"
                },
                {
                  "stringValue": "2021-08-26"
                }
              ]
            }
          }
        ]
      },
      {
        "recordId": "7b34e85d-f4e1-4099-89d9-02483128a6cd",
        "inboundEdges": [
          {
            "fromRecord": {
              "property_path_values": [
                {
                  "stringValue": "2021-08-26"
                }
              ]
            }
          }
        ]
      },
      {
        "recordId": "840f52e2-0f2e-4591-810d-19f9e8840a49",
        "inboundEdges": []
      }
    ]
  }
}

我不想要响应中的第三个结果,因为它inboundEdges数组是空的。

我想说的是:找到所有 records 至少有一个 inboundEdge 有一个 fromRecord 至少有一个 property_path_value 有一个stringValue 等于 2021-08-26。我不想解析需要用 inboundEdges === []

排除结果的响应

我似乎混淆了选择集和陈述查询的位置。做我想做的事情的正确方法是:

query MyQuery {
  records(where: {inboundEdges: {fromModelId: {_eq: "f0e19461-6d38-4148-8041-54eba6451293"}, fromRecord: {propertyPathValues: {stringValue: {_eq: "2021-08-26"}}}}, modelId: {_eq: "2f1f70b8-cb7b-487c-9e4c-ca03624ce926"}}) {
    recordId
  }
}

即把query放在where子句里,跟正常人一样,不是选择集