简体   繁体   English

如何有效地将 Hasura 查询的结果用于另一个查询?

[英]How to efficiently use the result of a Hasura query for another query?

I am currently querying my Hasura database using userId to get location.我目前正在使用 userId 查询我的 Hasura 数据库以获取位置。

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?有没有办法有效地组合这两个查询,以便我只查询一次?

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:您可以做的是创建一个 Postgres function 并查询 function ,而不是如 Hasura 的文档中所述:

https://hasura.io/docs/1.0/graphql/manual/schema/custom-functions.html#example-postgis-functions https://hasura.io/docs/1.0/graphql/manual/schema/custom-functions.html#example-postgis-functions

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM