使用AWS Amplify设置API连接时出现问题 [英] Problem with setting up API connection with AWS Amplify

查看:18
本文介绍了使用AWS Amplify设置API连接时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

运行‘Amplify Push’后,我收到以下错误消息:

�推送操作期间出错:未知指令‘Connection’。从架构中删除该指令或添加转换器来处理它。

出于某种原因,它不会将@Connection识别为自己的指令。

schema.graph ql中使用此指令的代码块如下:

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

我还没有找到任何解决方案,我感谢任何能在这方面帮助我的人。

推荐答案

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
}

这篇关于使用AWS Amplify设置API连接时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆