我想将表中的配置分配给响应。 答案的ID不在配置中。在答案中,有一个字段称为exam_id,而此exam_id是配置的ID
我有什么:
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
}
我想要什么:
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
}
当我请求答案时,我希望在响应中进行配置。 因此,对于每个exam_id,配置表中都有一个特殊的配置行。
答案 0 :(得分:0)
您可以使用连接注释的keyField
来分配它将使用的特定字段。如果您使用的是Amplify,则可以按照以下说明完成此操作:https://aws-amplify.github.io/docs/cli/graphql#connection
您的配置声明可能类似于:
config:ExamConfig @connection(名称:“ ExamConfigs” keyField:“ exam_id”)
希望这会有所帮助。