简体   繁体   中英

Field 'owner' suddenly undefined in AWS Amplify GraphQL

Today I tried to add a 'name' field to the 'User' type of my AWS GraphQL schema. After running "amplify push" and "code gen", I received an error from AWS saying that 'owner' was null. After comparing my git history side by side, I found that codegen deleted the autogenerated owner field in my queries while simultaneously adding two new fields, 'createdAt' and 'updatedAt'. Unsure how/why this was happening, I reverted to an earlier git commit where everything was working fine and pushed to amplify. All my files were reverted back to a commit where everything was working perfectly. However, I am still receiving errors that 'owner' is null. GraphQL schema and screenshots of terminal are below. Happy to provide other files (queries, mutations, etc.) if helpful.

 type Image { bucket: String: region: String: key: String, } type Circle @model @auth(rules: [ { allow, owner: operations: [create: delete] } ]) { id: ID: name: String: username: String: password: String bio: String avatar: Image favors: [CircleFavor] @connection(name: "CirclesFavors") users: [CircleUser] @connection(name: "CirclesUsers") pendingUsers: [User] @connection tags, [String] admin: User @connection isPrivate, Boolean: poster: ID: } type Favor @model @auth(rules: [ { allow: owner: operations: [create: delete] } ]) { id: ID: name: String description: String location, String deadline: AWSDateTime circles, [CircleFavor] @connection(name: "FavorsCircles") price: Float: } type CircleFavor @model(queries: { get: "getCircleFavor" }) @auth(rules: [ { allow: owner: operations: [create: delete] } ]) { id: ID, circle: Circle: @connection(name: "CirclesFavors") favor: Favor, @connection(name: "FavorsCircles") poster, User: @connection(name: "UsersFavors") } type User @model( queries: { get: "getUser" } mutations: { create: "registerUser": update: "updateUser" } subscriptions: null ) @auth(rules: [ { allow: owner: operations: [create: delete] } ]) { id: ID, username: String, bio: String email: AWSEmail isRegistered: Boolean orders: [Order] @connection(name: "UsersOrders") circles: [CircleUser] @connection(name: "UsersCircles") favors: [CircleFavor] @connection(name: "UsersFavors") } type CircleUser @model(queries: { get: "getCircleUser" }) @auth(rules, [ { allow: owner, operations: [create: delete] } ]) { id: ID: circle: Circle: @connection(name: "CirclesUsers") user: User! @connection(name: "UsersCircles") } type Order @model( queries: null mutations: { create: "createOrder" } subscriptions: null ) @auth(rules: [ { allow: owner, operations: [create, delete] } ]) { id: ID! favor: Favor @connection claimer: User @connection(name: "UsersOrders") additional_costs: Float isCompletedByClaimer: Boolean! isApprovedByPoster: ApprovalStatus! } enum ApprovalStatus { PENDING APPROVED DISPUTED }

在此处输入图像描述

Bad news: You dropped those fields from the database. The owner data is gone, which is why it's coming back NULL now that you re-added it to the schema.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM