当我尝试#foreach在 VTL 响应模板中返回循环时,即使我有 116 个项目,它也不会返回超过 101 个项目。为了测试,我创建了两个字段items并itemCount运行相同的 ES 查询。
VTL 响应映射items:
[
  #foreach($entry in $context.result)
    #if( $velocityCount > 1 ) , #end
    $util.toJson($entry.get("_source"))
  #end
]
VTL 响应映射itemCount:
$context.result.size()
appsync 似乎对 foreach 循环设置了限制(参考:http://people.apache.org/~henning/velocity/html/ch05s04.html)。
是否可以在 graphql 订阅上获得联合结果,特别是在 AppSync 中?
我在 AppSync 中尝试了以下操作,但收到错误“订阅的输出类型无效”
type Mutation {
  test1Mutation(test1arg: Test1Input!): Test1,
  test2Mutation(test2arg: Test2Input!): Test2
}
union DataMutationResult = Test1 | Test2
type Subscription {
    dataMutation(id: ID!): DataMutationResult
      @aws_subscribe(mutations: ["test1Mutation", "test2Mutation"])
}
使用 AWS Appsync 开发 React 应用程序并首次尝试 graphQL。我的schema.graphql对我来说是有意义的,但抛出一个错误,我真的不知道如何查看发生了什么。
这是一个用户可以通过通知系统发帖和评论的应用程序。收到Resource is not in the state stackUpdateComplete错误消息amplify push
type User @model {
  id: ID!
  following: [User]
  follower: [User]
  post: [Post] @connection(name: "UserPost")
  comment: [Comment] @connection(name: "UserComment")
  notification: [Notification] @connection(name: "UserNotification")
}
type Post @model {
  id: ID!
  user: User! @connection(name: "UserPost")
  privacy: String!
  content: String!
  loved: [User]
  comment: [Comment] @connection(name: "PostComment")
}
type Comment @model {
  id: ID!
  user: User! @connection(name: "UserComment")
  content: String!
  loved: [User]
  post: Post …我当前正在使用 AppSync 来查询 GSI。我已经能够在管道解析器函数中成功使用此代码块,但我不知道为什么当我尝试在传统解析器中使用它时它不起作用。
我目前收到映射模板错误:
{
  "data": {
    "units": null
  },
  "errors": [
    {
      "path": [
        "units"
      ],
      "data": null,
      "errorType": "MappingTemplate",
      "errorInfo": null,
      "locations": [
        {
          "line": 2,
          "column": 3,
          "sourceName": null
        }
      ],
      "message": "Value for field '$[version]' not found."
    }
  ]
}
我尝试在 AWS 文档中搜索,但向 GraphQL 类型添加“版本”不起作用。
我也尝试过这个(即使我没有使用S3) AppSync S3Object检索 和文档: https: //docs.aws.amazon.com/appsync/latest/devguide/troubleshooting-and-common-mistakes.html#mapping -模板错误
这是请求映射模板:
#set($arg=$context.args)
    {
    "operation": "Query",
    "index" : "userPK-userSK-index",
    "query": {
        "expression": "userPK = :pk and begins_with(userSK, :sk)",
        "expressionValues": {
            ":pk": {"S": "tenant:${arg.tenantId}" }, …我在 React 应用程序中使用基于 AWS 的无服务器架构以及 AppSync、Cognito 和 GraphQL。过去,我能够在本地更新我的 graphql 架构并运行amplify api push,它成功地将我的所有更改推送到云。
amplify api push最近我一直在尝试通过我在通行证中更新云,并且终端显示“所有资源都在云中更新”。但是,它将我的架构恢复为上次推送时的架构版本。不用说,它也没有在云端更新。
终端中没有显示任何错误消息。
我想要做的改变如下:
前-
type Topic @model {
  id: ID!
  postID: ID!
  name: String!
}
后-
type Topic @model {
  id: ID!
  name: String!
}
任何帮助都感激不尽
CloudFormation 提供了AWS::AppSync::ApiKey资源类型,用于在 CloudFormation 堆栈中创建 AppSync API 密钥。API 密钥将过期。是否有一种简单的方法可以在 CloudFormation 中定义轮换计划?我什么也没看到,但它似乎是一个如此明显的用例,我不确定没有它的 AWS::AppSync::ApiKey 资源类型有什么好处。
目前我有一个 lambda,它按计划运行以生成新密钥并将其存储在 SecretsManager 中。这有效,但这是一个额外的步骤,我必须在第一次手动运行 lambda。我对替代品持开放态度。
我正在使用 AWS Amplify,我想知道最好将用户属性存储为自定义 Cognito 属性还是 AppSync 的用户表?
'username': 'jdoe',
'password': 'mysecurepassword#123',
'attributes': {
    'email': 'me@domain.com',
    'phone_number': '+12135555555',
    'custom:favorite_flavor': 'Cookie Dough'  // custom attribute, not standard
}
type User 
    @model 
    @auth(
        rules: [
          {allow: owner, ownerField: "owner", operations: [create, update, delete, read]},
        ])
{
    id: ID!
    owner: String
    favoriteFlavor: String
}
如果 AppSync 方法是最好的,其他字段是否应该保留到表中(例如姓名或电子邮件)?
谢谢!
我正在开发一个无服务器 Reactjs 项目,并使用 AWS amplify 来管理我的用户。我在测试中注意到,如果我以用户身份登录,第二天当我访问该网站时仍然会登录。我阅读了 Amplify 的文档,该库会自动刷新令牌,并且想知道是否可以禁用此功能,以便用户在几个小时不活动后必须重新登录该网站。
谢谢。
我一直在尝试与 AppSync/GraphQL 进行交互:
邮政:
mutation MyMutation {
  updateAsset(input: {
      id: "b34d3aa3-fbc4-48b5-acba-xxxxxxxxxxx",
      owner: "51b691a5-d088-4ac0-9f46-xxxxxxxxxxxx",
      description: "AppSync"
    }) {
    id
    owner
    description
  }
}
回复:
{
  "data": {
    "updateAsset": {
      "id": "b34d3aa3-fbc4-48b5-acba-xxxxxxxxxx",
      "owner": "51b691a5-d088-4ac0-9f46-xxxxxxxxxxx",
      "description": "Edit Edit from AppSync"
  }
}
每次我发送查询时,DynamoDB 中的版本都会自动递增。但描述仍与最初设定的相同。
架构上的身份验证规则 -
@auth(
    rules: [
        { allow: public, provider: apiKey, operations: [create, update, read] },
        { allow: private, provider: userPools, operations: [read, create, update, delete] } …我已将放大版本从 升级4.45.0到5.2.0,
现在,当我这样做时amplify push,我收到以下错误:
Following resources failed
Resource Name: ci5lt23eofhvxlc3an7db4d7veGraphQLSchema (AWS::AppSync::GraphQLSchema)
Event Type: update
Reason: The specified key does not exist. (Service: Amazon S3; Status Code: 404; Error Code: NoSuchKey; Request ID: GZQF1T9HWCCED75H; S3 Extended Request ID: qicfcwF2YUNdqMDU3EUkt+hsXIQawcirDG7TIX+peEEkAWOE1v9ee6n2L5Qc2I8uePyAXg2eJ4U=; Proxy: null)
aws-appsync ×10
aws-amplify ×5
graphql ×5
amplify ×1
reactjs ×1
schema ×1
serverless ×1
session ×1