graphql - 我只能在 Appync 上使用 GraphQL 中的主键进行查询?
问题描述
这个问题让我大吃一惊。
我正在尝试在 graphql 查询中使用非主键查询 RDS 表。
这是我在 appsync 中的两个查询的示例
query getloc{
getLocationByCounty(County: "County"){
LocationsID
State
County
}
}
query getLocations{
getLocation(LocationsID: 1){
LocationsID
State
County
}
}
此处的第二个查询有效,并准确返回具有该 LocationID 的县。第一个返回错误消息:“不能为不可为空的类型返回 null:父 'Locations' (/getLocationByCounty/LocationsID) 内的 'Int'”
如果我更改位置的架构并使 LocationsID 不可为空,则错误消失,但它返回 null。
{
"data": {
"getLocationByCounty": {
"State": null
}
}
}
我的 getLocationsByCounty 请求解析器是:
"version": "2018-05-29",
"statements": ["select * from Locations where County = '$ctx.args.County'"]
这是响应解析器:
## Raise a GraphQL field error in case of a datasource invocation error
#if($ctx.error)
$utils.error($ctx.error.message, $ctx.error.type)
#end
$utils.toJson($utils.rds.toJsonObject($ctx.result)[0])
这在graphQL中是不允许的还是我做错了???
值得注意的是,如果我只是做这个查询:
select * from Locations where County = 'County'
在 mySQL 中,它完全按预期工作。
解决方案
推荐阅读
- r - R RSelenium/seleniumPipes 未知错误:找不到 Chrome 二进制文件
- c# - 代码中未指定交易所的 MassTransit ACCESS_REFUSED
- rest - 可选功能参数的 REST GET 设计
- r - 如何在 R 中为所需的货币符号和括号“()”中的负数格式化数据表或矩阵
- php - 使用php在mysql中进行行编号
- linux - 如何在不运行 source 命令的情况下将子 shell 的执行行打印到主 shell?
- django-admin - 使用 Django-import-export 在 Django Admin 中导入行后,如何获取 Id?
- laravel - 测试期间的 Laravel 模拟策略
- javascript - HighStock Depthchart 正在奇怪地更新数据
- coq - 为什么嵌套归纳策略也将归纳假设嵌套在 lambda 下?