我一直在研究 GraphQL 并触发查询以将 JSON 响应获取到反应应用程序中。
但我需要触发一个查询,它将返回列中的最大值和最小值。
我已经浏览了 GraphQL 的文档,但没有找到实现此目的的方法。
{
schneider(where: {_and: [{device_time: {_gte: "2018-09-04T20:11:42.097+05:30"}}, {device_time: {_lte: "2018-09-04T20:12:43.187+05:30"}}]}) {
active_energy_received
}
}
上面的查询为我提供了两个提供日期之间的值列表。
{
"data": {
"schneider": [
{
"active_energy_received": 0
},
{
"active_energy_received": 0
},
{
"active_energy_received": 0
},
{
"active_energy_received": 0
},
{
"active_energy_received": 0
},
{
"active_energy_received": 0
},
{
"active_energy_received": 0
},
{
"active_energy_received": 0
},
{
"active_energy_received": 0
},
{
"active_energy_received": 0
},
{
"active_energy_received": 4.3699998856
},
{
"active_energy_received": 0.82099998
},
{
"active_energy_received": 0.82099998
},
{
"active_energy_received": 4.3699998856
},
{
"active_energy_received": 0.82099998
},
{
"active_energy_received": 4.3699998856
},
{
"active_energy_received": 0.82099998
},
{
"active_energy_received": 4.3699998856
},
{
"active_energy_received": 0.82099998
},
{
"active_energy_received": 4.3699998856
},
{
"active_energy_received": 0.82099998
},
{
"active_energy_received": 4.3699998856
},
{
"active_energy_received": 0
},
{
"active_energy_received": 0.820999979972839
},
{
"active_energy_received": 4.3699998856
}
]
}
}
现在,我只想要这个列表中的最大值和最小值,而不是所有值。
更新:
我将 hasura.io 与 postgreSQL 一起使用。