【问题标题】:Problem with setting up API connection with AWS Amplify使用 AWS Amplify 设置 API 连接时出现问题
【发布时间】:2022-01-16 21:16:17
【问题描述】:

我目前正在 React Native Expo 中开发一个利用 AWS amplify 的电子商务应用程序,我正在尝试将 API 和数据库连接到它。

运行“放大推送”后,我收到以下错误消息:

� 推送操作期间发生错误:未知指令“连接”。从架构中删除指令或添加转换器来处理它。

由于某种原因,它没有将@connection 识别为自己的指令。

schema.graphql 中使用该指令的代码块如下:

type CartProduct @model @auth(rules: [{allow: public}]){
    id: ID!
    userSub: String!
    quantity: Int!
    option: String
    productID: ID!
    product: Product @connection(fields: ["productID"])
}

我在任何地方都没有找到解决方案,我感谢任何可以帮助我的人。

【问题讨论】:

    标签: react-native aws-amplify flutter-aws-amplify


    【解决方案1】:

    aws-amplify repo 中的This github issue 帮助我解决了类似的错误。问题的要点是解释架构定义的graphql转换器版本是upgraded to v2,@key和@connection指令在版本1指令中。

    对于版本 2,我使用了 @hasMany 和 @hasOne 指令。

    type PurchaseOrder @model @auth(rules: [{ allow: owner }]) {
      id: ID!
      poNumber: String
      dateOrdered: AWSDateTime
      dateRequested: AWSDateTime
      dateReceived: AWSDateTime
      notes: String
      subtotal: Float
      taxRate: Float
      salesTax: Float
      priceAdjustment: Float
      discount: Float
      total: Float
      requestor: String
      paymentTerms: String
      shipping: Float
      comments: String
      billingAddress: Address @hasOne
      shippingAddress: Address @hasOne
      shippingInformation: String
      customerId: String
      createdAt: AWSDateTime!
      updatedAt: AWSDateTime!
      poItems: [PoItem] @hasMany
      attachments: [Attachment] @hasMany
      vendorID: ID!
      vendor: Vendor @hasOne
    }
    

    【讨论】:

    • 感谢您的建议。我想我必须研究更多 GraphQL 指令,然后尝试一下。
    猜你喜欢
    • 2021-01-21
    • 2020-04-29
    • 2021-05-31
    • 2019-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-09
    相关资源
    最近更新 更多