我花了最后一天尝试AWS AppSync我对订阅可以做什么有点失望.在我看来,当前状态AppSync subscription是针对用例的情况,你有一个项目列表,你希望它在所有客户端同步.
与apollo-subscription相比,它相当有限.
所以,如果我理解正确的文件:
我有一些用例,像Post上的投票这样的突变可能会导致将不同类型的数据推送到Post的所有者.
我有一些用例,其中突变甚至查询可以导致向正在侦听事件的特定目标发送推送.
如果我错了,你可以纠正我吗?
我的服务需要用户组来授权访问数据.
AppSync文档中的组授权示例基于用户池声明.我正在使用IAM身份验证,因此$ context.identity不包含声明或任何类似信息.
例如,请参阅以下网址中的 "用例:组可以创建新记录"主题:https: //docs.aws.amazon.com/appsync/latest/devguide/security-authorization-use-cases.html
#set($expression = "")
#set($expressionValues = {})
#foreach($group in $context.identity.claims.get("cognito:groups"))
    #set( $expression = "${expression} contains(groupsCanAccess, :var$foreach.count )" )
    #set( $val = {})
    #set( $test = $val.put("S", $group))
    #set( $values = $expressionValues.put(":var$foreach.count", $val))
    #if ( $foreach.hasNext )
    #set( $expression = "${expression} OR" )
    #end
#end
{
    "version" : "2017-02-28",
    "operation" : "PutItem",
    "key" : {
        ## If your table's hash key is not named 'id', update it here. **
        "id" : { "S" …我有一个客户端应用程序订阅了Appysync事件。数据源是RDS的Lambda函数。是否可以从Lambda函数中调用在RDS更新时触发的变异?
我计划将AWS Cognito用于用户身份验证,使用DynamoDB进行持久性,并使用AppSync(和许多Mobile Hub)来为API提供支持 - 书评网站.
我很难确定哪个字段应该是我的哈希键,哪个应该是我的排序键,以及我应该创建哪个LSI/GSI.
我有一份书籍清单,详细信息如下:
type Book {
  isbn: Int!
  year: Int!
  title: String!
  description: String
  front_cover_photo_url: String
  genre_ids: [Int]
  count_thumbs: Int
  us_release_date: String
  upcoming_release: Boolean
  currently_featured_in_book_stores: Boolean
  best_seller: Boolean
  reviews: [Review]
}
每次用户撰写有关图书的评论时,我也会有评论记录.
type Review {
  isbn: Int!
  id: ID!
  created_at: String!
  # The user that submitted the review
  user_id: String!
  # The number of thumbs out of 5
  thumbs: Int!
  # Comments on the review
  comments: String!
}
在我的案例中,书籍可以有多种类型 - 例如"幻想"和"戏剧".书籍也有用户评论,其数据存储在Cognito中.我们将在每本书旁边以反向时间顺序显示评论.
问题1:如果我将非规范化并Drama用作流派而不是流派ID 2 …
amazon-web-services amazon-dynamodb amazon-cognito graphql aws-appsync
使用AppSync和DynamoDB作为数据库源时,如何自动生成ID ?
我有一个看起来像下面的类型
type Post {
    id: ID!
    creator: String!
    createdAt: String!
    like: Int!
    dislike: Int!
    frozen: Boolean!
}
和输入如下所示
input CreatePostInput {
    id: ID!
    creator: String!
    createdAt: String!
    like: Int!
    dislike: Int!
    frozen: Boolean!
}
而我的突变显然是两者的结合
createPost(input: CreatePostInput!): Post
但是,当我进行插入时,我必须执行以下操作
mutation createPost{
  createPost(input:{
    id:2
    creator:"some creator"
    createdAt:"some date"
    like:0
    dislike:0
    frozen:false
  }){
    id
    creator
    createdAt
    like
    dislike
    frozen
  }
}
我无法插入帖子而不必知道当前id正在做什么。在插入表之前,有什么方法可以提供null,也可以提供任何随机值id,DynamoDB或者AppSync自动创建下一个索引吗?
我更新时
input CreatePostInput不接受任何错误 …
我们在使用参数订阅时遇到了巨大的麻烦
简化问题以下是重现的步骤
创建一个simpleSchema
type Mutation {
    testSubMutation(param: String!): String
}
type Query {
    testQuery: String
}
type Subscription {
    testSubs(param: String): String
        @aws_subscribe(mutations: ["testSubMutation"])
}
我将一个本地解析器附加到返回时间戳的突变上.
在一个窗口中打开应用程序同步查询选项卡并进行订阅
subscription sub{
  testSubs
}
在另一个窗口做一个变异
mutation mut{
  testSubMutation(param:"123")
}
奇迹般有效
现在更改订阅以侦听参数
subscription sub{
  testSubs(param:"123")
}
不再工作了.:(
任何帮助表示赞赏.
我有一个DynamoDB连接到步骤功能,并且正在构建一个UI以显示更改。我将数据库连接到AppSync实例,并尝试通过AppSync使用预订,但似乎它们仅观察到当前AppSync中的突变。
如何直接订阅数据源更改?
在AWS AppSync中,似乎不会将在主查询上发送的参数转发给所有子解析器。
type Query {
  article(id: String!, consistentRead: Boolean): Article
  book(id: String!, consistentRead: Boolean): Book
}
type Article {
  title: String!
  id: String!
}
type Book {
  articleIds: [String]!
  articles: [Article]!
  id: String!
}
当我打电话时:
query GetBook {
  book(id: 123, consistentRead: true) {
    articles {
      title
    }
  }
}
获取书的第一个查询在中接收consistentRead参数$context.arguments,但随后的检索文章的查询则没有。($context.arguments为空)
我也尝试过articles(consistentRead: Boolean): [Article]!里面book但是没有运气。
有谁知道在AppSync中是否可以将参数传递给同一请求的所有查询?
我知道上下文是您在Lambda函数中定义的名称,但是对于Appsync解析器,我有点困惑。我已经看到了两者$ctx,$context并在包括AWS文档在内的AppSync解析器中使用了它们。AWS自己的一些代码生成工具(例如AWS Amplify CLI)会创建在同一代码中使用两者的解析器!我在文档中找不到任何解释此内容的信息。这里发生了什么?
amazon-web-services graphql aws-appsync aws-appsync-ios appsync-apollo-client