Reputation: 1037
I am currently querying my Hasura database using userId to get location.
users(where: {id: {_eq: 1528}}) {
location
}
I then use location to query users near that one user.
users(
where:
{ location: {_st_d_within: {distance: 20000, from: $point }}},
) {
firstName
city
region
}
}
Is there a way to efficiently combine these two queries such that I only query once?
Upvotes: 2
Views: 2081
Reputation: 222
You can not combine these two queries into one.
What you can do is create a Postgres function and query that function instead as described in Hasura's documentation:
https://hasura.io/docs/1.0/graphql/manual/schema/custom-functions.html#example-postgis-functions
Upvotes: 3