multiple usequeries in a single component
Indeed you can use multiple queries
const queryMultiple = () => {
const res1 = useQuery(Get_Doctor);
const res2 = useQuery(GET_Branch);
return [res1, res2];
}
const [
{ loading: loading1, data: data1 },
{ loading: loading2, data: data2 }
] = queryMultiple()
What you want to do is compose multiple useQuery into your own custom hook:
Reference
But still, its just a syntactic sugar
const { data:doc_data } = useQuery(Get_Doctor);
const { data:branch_data, error: branch_error, loading: branch_loading } = useQuery(GET_Branch);
You just have to rename the data field to have it work. Note that you will have to rename the other
fields like error, loading
etc if any of your queries will be returning them.