Graphql 对象(或 JSON)作为过滤器参数
Graphql object ( or JSON) as filter argument
是否可以在过滤器参数中提交一个 JSON 对象。类似于:
Query{
building(location:{lon,lat}){
name,...
}
}
我需要传递位置信息,我想将其作为 js 对象(给 apollo 客户端)或字符串化的方式传递 JSON。
您可以使用 input types 来实现。您需要编辑架构
type Query {
building(location: Location): Building
}
input Location {
lon: String
lat: String
}
然后你可以post你的查询像这样
query {
building(location: {lon:"100.332680",lat:"5.416393"}) {
name,...
}
}
是否可以在过滤器参数中提交一个 JSON 对象。类似于:
Query{
building(location:{lon,lat}){
name,...
}
}
我需要传递位置信息,我想将其作为 js 对象(给 apollo 客户端)或字符串化的方式传递 JSON。
您可以使用 input types 来实现。您需要编辑架构
type Query {
building(location: Location): Building
}
input Location {
lon: String
lat: String
}
然后你可以post你的查询像这样
query {
building(location: {lon:"100.332680",lat:"5.416393"}) {
name,...
}
}