[英]Hasura Graphql- How to pass Output of one Query as an input to the other Query?
I am new to Postgres DB and Hasura-Graphql.我是 Postgres DB 和 Hasura-Graphql 的新手。 It would be good if anyone can help me out.
如果有人能帮助我,那就太好了。
So there are two tables, Table1 with( username, email, id, table1id) and Table2 with (username, email, booksRead, visitedLocations, table2_id).所以有两个表,Table1 有(用户名,email,id,table1id)和 Table2 有(用户名,email,booksRead,visitedLocations,table2_id)。 These two tables are not connected( either by PK or FK).
这两个表没有连接(通过 PK 或 FK)。
Now the question is I have to query from table1 to get uername and email with that I need to query table2.现在的问题是我必须从 table1 查询以获取 uername 和 email 我需要查询 table2。 So is there anyway where I can add output of one query as the input to the another query in the one query.
那么无论如何我可以将一个查询的 output 添加为一个查询中另一个查询的输入。
Also note that I need to go from table1 to table2 for some other details.另请注意,我需要 go 从 table1 到 table2 以获取其他一些详细信息。
For example:例如:
query{
table1{
username,
email
}
table2(where:{username:username, email:email}){
username,
email,
visitedLocations,
booksRead
}
}
You should use table relationships or custom functions .您应该使用表关系或自定义函数。
What you want to do is not very clear, but I think you should redesign your database schema:你想做什么不是很清楚,但我认为你应该重新设计你的数据库架构:
So, querying could be:因此,查询可能是:
query {
user {
username
email
visitedLocations {
location
}
booksRead {
book
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.