AWS AppSync - 为缺少自定义类型和枚举的模式创建资源
AWS AppSync - Creating Resources for schema missing custom types and enums
我知道枚举在 Dynamo 中不是标准类型:https://forums.aws.amazon.com/thread.jspa?messageID=836386
但是,这里的确切分辨率是多少?
我们应该如何适当地表示与生成代码的关系?
-- 我是不是遗漏了什么或者生成的代码是否正确,我们需要在 dynamo tables 中创建一些自定义字段然后重写查询?
示例:
type Competition {
id: ID!
name: String!
creator: UserProfile!
startDate: String!
endDate: String!
competitionType: CompetitionType!
competitors: [UserProfile]!
prize: Prize!
}
比赛由用户创建,有类型,有奖品,有参赛者。当 create resources
对于此 table 时,代码显然缺少从自定义类型或枚举派生的任何信息。复杂的模式总是有这种类型的结构,所以我对输出的代码和从这里开始的正确方向有点困惑。
extend type Mutation {
createCompetition(input: CreateCompetitionInput!): Competition
}
input CreateCompetitionInput {
id: ID!
name: String!
startDate: String!
endDate: String!
## Missing info
}
当 AppSync 自动生成架构时,它会跳过这些,因为它们旨在使用其他解析器手动添加。您可以定义一个附加到每个自定义或枚举字段的新查询,但是您引用的数据需要用竞争独有的东西来标记,以便可以查询与此类型相关的数据(因为 dynamoDB 不是关系数据库)。
创建新竞赛时,您需要使用该竞赛独有的内容更新子字段。 IE。每个需要跟踪为竞争对手的 UserProfile 都会被标记上这个竞赛 ID。每个自定义字段的变更都需要单独处理。
这篇文章帮助我解决了同样的问题:https://keyholesoftware.com/2018/05/17/go-forth-and-appsync/。
我知道枚举在 Dynamo 中不是标准类型:https://forums.aws.amazon.com/thread.jspa?messageID=836386
但是,这里的确切分辨率是多少? 我们应该如何适当地表示与生成代码的关系?
-- 我是不是遗漏了什么或者生成的代码是否正确,我们需要在 dynamo tables 中创建一些自定义字段然后重写查询?
示例:
type Competition {
id: ID!
name: String!
creator: UserProfile!
startDate: String!
endDate: String!
competitionType: CompetitionType!
competitors: [UserProfile]!
prize: Prize!
}
比赛由用户创建,有类型,有奖品,有参赛者。当 create resources
对于此 table 时,代码显然缺少从自定义类型或枚举派生的任何信息。复杂的模式总是有这种类型的结构,所以我对输出的代码和从这里开始的正确方向有点困惑。
extend type Mutation {
createCompetition(input: CreateCompetitionInput!): Competition
}
input CreateCompetitionInput {
id: ID!
name: String!
startDate: String!
endDate: String!
## Missing info
}
当 AppSync 自动生成架构时,它会跳过这些,因为它们旨在使用其他解析器手动添加。您可以定义一个附加到每个自定义或枚举字段的新查询,但是您引用的数据需要用竞争独有的东西来标记,以便可以查询与此类型相关的数据(因为 dynamoDB 不是关系数据库)。
创建新竞赛时,您需要使用该竞赛独有的内容更新子字段。 IE。每个需要跟踪为竞争对手的 UserProfile 都会被标记上这个竞赛 ID。每个自定义字段的变更都需要单独处理。
这篇文章帮助我解决了同样的问题:https://keyholesoftware.com/2018/05/17/go-forth-and-appsync/。