[英]How to modify GraphQL response in hasura?
I want to modify the response of hasura fetch query.我想修改 hasura fetch 查询的响应。
the current response is this:目前的回应是这样的:
{
"data": {
"ids": [
{
"id_object": {
"id": 33102
}
},
{
"id_object": {
"id": 33104
}
}
]
}
}
And I want to remove "id_object" and want just array of id's like this:我想删除“id_object”,只需要像这样的 id 数组:
{
"data": {
"ids": [
{
"id": 33102
},
{
"id": 33104
}
]
}
}
A GraphQL server exposes an exact set of operations and the shape of the allowed responses for those operations. GraphQL 服务器公开一组精确的操作以及这些操作的允许响应的形状。 When interacting with any GraphQL server (Hasura or otherwise), it is therefore not possible to to arbitrarily modify the shape of the returned data.
因此,在与任何 GraphQL 服务器(Hasura 或其他)交互时,不可能随意修改返回数据的形状。
You're free to map it into a new form when you receive the data on the client side.当您在客户端收到数据时,您可以自由地将其映射到新的表单中。
If you really need the server itself to be able to respond using this shape, you'll need to extend Hasura's schema to be able to specifically support this query pattern.如果您确实需要服务器本身能够使用此形状进行响应,则需要扩展 Hasura 的架构以能够专门支持此查询模式。
There are a number of different ways that you could accomplish this:您可以通过多种不同的方式来实现这一点:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.