aws-amplify - Schema @connection to a special field
问题描述
I would like to assign configs from a table to responses. The ID of the answer is not in the configs. In the answer there is a field called exam_id and this exam_id is the ID of the config
what i have:
type Answer @model {
id: ID!
exam_id: String!
user: User! @connection(name: "Answers")
cycle: Int
user_input: AWSJSON
aivy_output: AWSJSON
final_scores: AWSJSON
score: Int
rating: Int
createdAt: String
updatedAt: String
}
type ExamConfig @model {
id: ID!
item_count: Int
zscore_mean: AWSJSON
zscore_deviation: AWSJSON
}
what i want:
type Answer @model {
id: ID!
exam_id: String! // = TOWER_OF_LONDON
config: ExamConfig @connection //BUT it have to be exam_id == ID from Config
user: User! @connection(name: "Answers")
cycle: Int
user_input: AWSJSON
aivy_output: AWSJSON
final_scores: AWSJSON
score: Int
rating: Int
createdAt: String
updatedAt: String
}
type ExamConfig @model {
**** id: ID! // = TOWER_OF_LONDON
item_count: Int
zscore_mean: AWSJSON
zscore_deviation: AWSJSON
}
when i request a Answer, than i want the config in the response. So for every exam_id is a special config row in the config Table.
解决方案
您可以使用keyField
连接注释的 来分配它将使用的特定字段。如果您使用的是 Amplify,请按照此处所述完成:https ://aws-amplify.github.io/docs/cli/graphql#connection
您的配置声明可能类似于:
配置:ExamConfig @connection(名称:“ExamConfigs”keyField:“exam_id”)
希望这可以帮助。
推荐阅读
- java - 如何获得多个条目的最高和最低分数
- sql - 将两个选择查询合并为一个结果
- plsql - wwv_flow_data_parser.parse 将值移动到错误的单元格
- java - 如何使用 Apache POI 从 excel 文件中读取值
- node.js - 从可观察对象返回的复杂对象中访问数据
- android - cordova.cmd build android 以退出代码 1 退出
- javascript - 如何使用 javascript 更改不透明度
- recharts - 有没有办法设置 XAxis 的背景颜色
- php - 为在主站点上使用的按钮创建 wordpress 简码
- android - 如何在点击开关时获取以前的开关值?