有个小问题(我猜)。我在码头群环境下创建了c# rest web。Rest正在通过邮递员进行正确的测试。然后,我尝试在同一个码头群环境下编写Hasura服务。控制台也正常工作。问题在于查询操作。
代码:
动作定义
type Query {
getWeatherForecast : [WeatherForecastResonse]
}新类型定义
type WeatherForecastResonse {
date : String
temperatureC : Int
temperature : Int
summary : String
}Handler
http://{api ip}:{api port}/WeatherForecast在尝试执行查询时:
query MyQuery {
getWeatherForecast {
temperature
summary
date
temperatureC
}
}我从响应中得到的只是json的错误:
{
"errors": [
{
"extensions": {
"internal": {
"error": "invalid json: Error in $: not enough input",
"response": {
"status": 405,
"body": "",
"headers": [
{
"value": "Mon, 14 Jun 2021 13:54:00 GMT",
"name": "Date"
},
{
"value": "Kestrel",
"name": "Server"
},
{
"value": "0",
"name": "Content-Length"
},
{
"value": "GET",
"name": "Allow"
}
]
},
"request": {
"body": {
"session_variables": {
"x-hasura-role": "admin"
},
"input": {},
"action": {
"name": "getWeatherForecast"
}
},
"url": "http://{api ip}:{api port}/WeatherForecast",
"headers": []
}
},
"path": "$",
"code": "unexpected"
},
"message": "not a valid json response from webhook"
}
]
}我通过使用postman调用:http://{api ip}:{api }/WeatherForecast (GET方法)获得了所需的响应。
我应该在哪里进行改进,以便最终从rest中获得所需的结果?
P.S. hasura版本:v2.0.0-字母4(也与v1.3.3一起尝试)
更新:发布了一个新版本的web。在WeatherForecastController内部包含了一个带有POST属性的新方法。查询保持不变,但现在graphql查询返回我想要的内容。
所以问题是:是否可以使用Hasura操作查询调用/访问带有GET属性的web方法?
发布于 2021-06-14 19:30:34
不,目前不可能,Hasura总是向操作处理程序发出POST请求:
当动作被执行时,即当查询或变异被调用时,Hasura使用动作参数和会话变量向处理程序发出POST请求。
来源:https://hasura.io/docs/latest/graphql/core/actions/action-handlers.html#http-handler
发布于 2022-02-23 16:22:39
在v2.1.0及更高版本中,我们可以使用REST连接器来实现这一点。Hasura动作RESTConnectors方法
转到控制台上的Actions选项卡,创建或修改操作。向下滚动以配置REST连接器。在“配置REST连接器”部分中,单击“添加请求选项转换”。
除此之外,你还可以做很多其他的配置。
https://stackoverflow.com/questions/67971639
复制相似问题