【问题标题】:Replacing PrimaryKey in AppSync Dynamo Schema替换 AppSync Dynamodb 架构中的主键
【发布时间】:2022-08-18 11:52:30
【问题描述】:

这是我的架构:

type Session @model @auth(rules: [{allow: public},{ allow: owner }, { allow: groups, groups: [\"Admin\"] }]) {
  sessionId: ID! @primaryKey
  numPeoplePresent: Int
  procedures: Procedures @hasOne
  notes: String
  cattle: [Cow] @manyToMany(relationName: \"CowSessions\")
}

这是我看到的错误:

errors: [Amplify.GraphQLError(message: \"Validation error of type FieldUndefined: Field \\\'id\\\' in type \\\'Session\\\' is undefined @ \\\'onCreateSession/id\\\'\", locations: nil, path: nil, extensions: nil)]
Recovery suggestion: The list of GraphQLError contains service-specific messages

我认为将 sessionId 作为主键将取代对 id 字段的需求,但我错了吗?

    标签: amazon-web-services amazon-dynamodb aws-amplify aws-appsync


    【解决方案1】:

    如果它没有坏,不要修复它的方法,只是回到使用常规的“id”而不是“sessionId”。

    【讨论】:

      【解决方案2】:

      您必须将 sessionId 类型更改为字符串,它应该可以工作。

      type Session @model @auth(rules: [{allow: public},{ allow: owner }, { allow: groups, groups: ["Admin"] }]) { sessionId:字符串! @首要的关键 numPeoplePresent: 整数 程序:程序@hasOne 备注:字符串 牛:[Cow] @manyToMany(relationName: "CowSessions") }

      【讨论】:

        猜你喜欢
        • 2019-07-25
        • 2019-02-18
        • 2019-09-05
        • 1970-01-01
        • 2020-07-24
        • 1970-01-01
        • 2019-12-11
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多