【发布时间】:2019-10-19 09:14:57
【问题描述】:
当initializing a new GraphQL backend via the Amplify CLI 时,示例模式使用@model 注释定义了多种类型。比如……
type Blog @model {
id: ID!
name: String!
posts: [Post] @connection(name: "BlogPosts")
}
type Post @model {
id: ID!
title: String!
blog: Blog @connection(name: "BlogPosts")
comments: [Comment] @connection(name: "PostComments")
}
type Comment @model {
id: ID!
content: String
post: Post @connection(name: "PostComments")
}
推送时,会创建多个 DynamoDB 表(每个模型一个)。因此,在此示例中,创建了三个单独的 DynamoDB 表(博客、帖子和评论)
在我们的例子中,我们有一个Users 模型,我们将有二十个左右的小集合与用户相关联。当感觉这些小集合都属于单个表中的 User 对象时,我对必须管理 20 个不同的 DynamoDB 表感到不安。
从我阅读的所有内容来看,AppSync 似乎在鼓励使用多个表。例如,以下来自 AWS AppSync 文档的屏幕截图中的 Note 明确指出,博客 cmets 应在生产环境中放入单独的表中。
这与DynamoDB documentation 中列出的最佳实践相矛盾:
您应该在 DynamoDB 应用程序中维护尽可能少的表。大多数设计良好的应用程序只需要一张表。
当使用 AppSync 时,每种类型是否都属于单独的 DynamoDB 表?
【问题讨论】:
标签: amazon-web-services amazon-dynamodb graphql aws-amplify aws-appsync