Hasura GraphQl在表中存在多个外键时,不会返回所有文档
查询:
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"
}
]
}
]
}
}
为什么第一个查询中的最后两个文档没有显示?
连接表定义:
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 版本那就太好了
Query:
user (where: { id: {_eq: 104}}) {
connections {
user1
user2
status
}
}
Response:
{
"data": {
"user": [
{
"id": 104,
"connections": [
{
"user1": 104,
"user2": 111,
"status": "pending"
}
]
}
]
}
}
Expected:
{
"data": {
"user": [
{
"id": 104,
"connections": [
{
"user1": 104,
"user2": 111,
"status": "pending"
},
{
"user1": 96,
"user2": 104,
"status": "connected"
},
{
"user1": 112,
"user2": 104,
"status": "pending"
}
]
}
]
}
}
Why are the last two documents not showing up from the first query?
Connection table definition:
CREATE TABLE connections
(
id Integer PRIMARY KEY,
user1 Integer,
user2 Integer
FOREIGN KEY (user1) REFERENCES users (id)
FOREIGN KEY (user2) REFERENCES users (id)
);
I know this could be more of a SQL question, but it would be great if you can show the graphql version too
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须在用户表和连接表之间创建两个关系,

然后查询:
输出:

You have to create two relationships between users table and connections table,

Then query :
Output:
