小编GBM*_*BMR的帖子

Amplify GraphQL 错误无权访问创建

在我的应用程序中,用户可以与其他用户开始对话,并且在创建对话后,他们可以互相发送消息。但是,在尝试在两个用户之间创建对话后,我收到一条错误消息

 Failed to create graphql GraphQLResponseError<Conversation>: GraphQL service returned a successful response containing errors: [Amplify.GraphQLError(message: "Not Authorized to access createConversation on type Conversation", locations: Optional([Amplify.GraphQLError.Location(line: 2, column: 3)]), path: Optional([Amplify.JSONValue.string("createConversation")]), extensions: Optional(["data": Amplify.JSONValue.null, "errorType": Amplify.JSONValue.string("Unauthorized"), "errorInfo": Amplify.JSONValue.null]))]
Recovery suggestion: The list of `GraphQLError` contains service-specific messages 
Run Code Online (Sandbox Code Playgroud)

这是我第一次使用 GraphQL,它可能表明了这一点。我想赋予members模型Conversation创建他们的 convo 的能力。有人能引导我走向正确的方向吗?以下是我的 GraphQL 架构

type User 
  @model 
  @auth(rules: [{ allow: owner, operations: [create, delete, update]}]) {
  id: ID!
  userSub: String!
  fullName: String!
  profileImageFileName: String!
  conversations: [ConvoLink] @connection(name: "UserLinks") …
Run Code Online (Sandbox Code Playgroud)

swift graphql aws-amplify

7
推荐指数
1
解决办法
1万
查看次数

如何从登录/注册 AWS Amplify 获取身份验证错误?

我目前正在尝试了解当用户尝试登录/注册时抛出什么类型的错误,但我的 switch case 不起作用,因为我不知道我应该与什么枚举进行比较。一旦确定了错误,应用程序就会显示一个 UIAlertController 来解释该错误。如果我print(err.code)只是得到一个 Int 回来。有人能引导我走向正确的方向吗?我找不到任何有关如何处理它的文档。

func signIn(username: String, password: String) {
    Amplify.Auth.signIn(username: username, password: password) { result in
        switch result {
        case .success:
            print("Sign in succeeded")
            //Go to root vc
        case .failure(let error):
            print("Sign in failed \(error)")
     if let err = error as NSError?{
          switch err.code {
                
          case AWSCognitoIdentityProviderErrorType.unknown.rawValue:
                        self.presentAlert(errorTitle: "Unkown Error", errorMessage: "An unknown error has occured", buttonText: "Ok")
                        print("Unkown error")
          case AWSCognitoIdentityProviderErrorType.invalidPassword.rawValue:
                        self.presentAlert(errorTitle: "Invalid Password", errorMessage: "You have entered an invalid password", buttonText: …
Run Code Online (Sandbox Code Playgroud)

swift aws-amplify

7
推荐指数
1
解决办法
2569
查看次数

如何获取用户库或相机中所选照片的​​ URL?

我有一个应用程序,用户可以在其中选择是要拍照还是从他们的库中选择一张照片。我拥有的代码获取了 Xcode 设备模拟器的图像 URL,但不适用于我的物理 iPhone。当我使用个人设备选择图像时 我的结果会打印出来

Failed: There is a client side validation error for the field [local] with message: The file located at the `local` URL is missing. Make sure the file exists before uploading to storage.
Run Code Online (Sandbox Code Playgroud)

但是当我使用设备模拟器运行时,它运行完美,图像存储在我的后端。我不确定为什么会发生这种情况。

我希望能够从我自己的设备获取 URL。

从 xcode 设备模拟器打印的 url

file:///Users/GBMR/Library/Developer/CoreSimulator/Devices/877A8184-D857-4211-94B1-00A6B724A956/data/Containers/Data/Application/094279FA-37B1-45E6-ABC4-ADAA08B5477B/PicturesB71286E4-1994-4D76-AC14-D40A062BC832.jpeg
Completed: ywassupo
Run Code Online (Sandbox Code Playgroud)

从我的物理 iPhone 打印的 url

file:///var/mobile/Containers/Data/Application/C0415B3C-F50E-4D20-8D8A-941D29B9C4D1/Pictures9BA481F9-C52A-40FD-8A06-AAA2D6CDA6D7.jpeg
Failed: There is a client side validation error for the field [local] with message: The file located at the `local` URL is missing. Make sure the file …
Run Code Online (Sandbox Code Playgroud)

swift

5
推荐指数
1
解决办法
366
查看次数

如何使用 GraphQL 创建一对多关系?

我有一个 iOS 应用程序,用户可以在其中使用后端 AWS Amplify 登录并相互发送消息。我的 API 是使用 GraphQL 配置的,目前看起来像这样。

type User @model {
  id: ID!
  userSub: String!
  fullName: String!
}
type ChatMessage @model {
  id: ID!
  senderUserSub: String
  recieverUserSub: String
  messageText: String
  messageImageFilename: String
  dateSent: String!
}

Run Code Online (Sandbox Code Playgroud)

我是 GraphQL 及其架构定义语言的新手。上面的架构有效,但是在 dynamodb 表内部没有结构,我正在尝试创建一种有效的方式来构建用户消息传递的数据。“一对多关系”是模式示例,可在配置 API 时在 Amplify CLI 中找到。我尝试复制它的示例基础我当前的一个。

默认一对多关系模式

type Blog @model {
  id: ID!
  name: String!
  posts: [Post] @connection(keyName: "byBlog", fields: ["id"])
}

type Post @model @key(name: "byBlog", fields: ["blogID"]) {
  id: ID!
  title: String!
  blogID: ID!
  blog: Blog …
Run Code Online (Sandbox Code Playgroud)

graphql aws-amplify

2
推荐指数
1
解决办法
2230
查看次数

如何在 AWS Lambda 函数中获取 eventName?

我对 AWS Lambda 很陌生。当我的表被修改时,我的 Lambda func 和 DynamoDB 表之间有一个触发器设置。Lambda 函数成功将事件打印到云监视日志。我有麻烦搞清楚如何检查事件是INSERTMODIFY在dynamoDB。我想检查一个if声明。当我刚print(event)得到

{
  "Records": [
    {
      "eventID": "26e6ac4f1c16fc40fd91536430c1ac72",
      "eventName": "MODIFY",
      "eventVersion": "1.1",
      "eventSource": "aws:dynamodb",
      "awsRegion": "us-east-1",
      "dynamodb": {
        "ApproximateCreationDateTime": 1612293148,
        "Keys": {
          "id": {
            "S": "d66ec59b-b807-4db9-96ed-3ebd3638779a450b7a75-6dce-4be9-babf-1077adb84b02"
          }
        },
        "NewImage": {
          "__typename": {
            "S": "Conversation"
          },
          "members": {
            "L": [
              {
                "S": "450b7a75-6dce-4be9-babf-1077adb84b02"
              },
              {
                "S": "d66ec59b-b807-4db9-96ed-3ebd3638779a"
              }
            ]
          },
          "isRead": {
            "BOOL": false
          },
          "recipient": {
            "S": "d66ec59b-b807-4db9-96ed-3ebd3638779a"
          },
          "latestMessage": {
            "S": "Hey man" …
Run Code Online (Sandbox Code Playgroud)

python amazon-web-services aws-lambda

1
推荐指数
1
解决办法
183
查看次数