当多个外键存在于同一个外字段的 table 中时,Hasura Graphql 不会 return 所有文档

Hasura Graphql does not return all documents when multiple foreign keys exist in a table to the same foreign field

查询:

user (where: { id: {_eq: 104}}) {
    connections {
      user1
      user2
      status
    }
  }

回复:

{
  "data": {
    "user": [
      {
        "id": 104,
        "connections": [
          {
            "user1": 104,
            "user2": 111,
            "status": "pending"
          }
        ]
      }
    ]
  }
}

预计:

{
  "data": {
    "user": [
      {
        "id": 104,
        "connections": [
          {
            "user1": 104,
            "user2": 111,
            "status": "pending"
          },
          {
            "user1": 96,
            "user2": 104,
            "status": "connected"
          },
          {
            "user1": 112,
            "user2": 104,
            "status": "pending"
          }
        ]
      }
    ]
  }
}

为什么第一个查询中没有显示最后两个文档?

连接table定义:

CREATE TABLE connections 
(
    id Integer PRIMARY KEY,
    user1 Integer,
    user2 Integer
    FOREIGN KEY (user1) REFERENCES users (id)
    FOREIGN KEY (user2) REFERENCES users (id)
);

我知道这可能更像是一个 SQL 问题,但如果您也能显示 graphql 版本就更好了

您必须在用户 table 和连接 table 之间创建两个关系,

然后查询:

query MyQuery {
  user(where: {id: {_eq: 104}}) {
    connections {
      user1
      user2
      status
    }
    connectionsByUser2 {
      user1
      user2
      status
    }
  }
}

输出: