Reputation: 166
I am new to Postgres DB and 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). These two tables are not connected( either by PK or FK).
Now the question is I have to query from table1 to get uername and email with that I need to query table2. So is there anyway where I can add output of one query as the input to the another query in the one query.
Also note that I need to go from table1 to table2 for some other details.
For example:
query{
table1{
username,
email
}
table2(where:{username:username, email:email}){
username,
email,
visitedLocations,
booksRead
}
}
Upvotes: 0
Views: 892
Reputation: 4714
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
}
}
}
Upvotes: 1