I am using Amplify for iOS to create the models.
I am trying to set up storage of user information after logging in with AWS Cognito. Setting up all the connections would be a lot easier if the id of the user items was the same as their Cognito subs.
Before setting the ownerField to "id" (and leaving it as the default "owner"), I was able to create users through the AppSync console interface in AWS. After changing the ownerField to "id" however, it gives me the following error. I am sure I was doing it through User Pools and not through IAM when testing it out. Querying still works through even when ownerField is on "id"
{
"data": {
"createUser": null
},
"errors": [
{
"path": [
"createUser"
],
"data": null,
"errorType": "Unauthorized",
"errorInfo": null,
"locations": [
{
"line": 2,
"column": 3,
"sourceName": null
}
],
"message": "Not Authorized to access createUser on type User"
}
]
}
Here is the relevant GraphQL model structure
type User @model
@auth (
rules: [
{ allow: owner, provider: userPools, ownerField: "id" },
{ allow: private, provider: iam, operations: [read] },
{ allow: public, provider: iam, operations: [read] }
]
) {
id: ID!
username: String
firstName: String
lastName: String
email: String
gender: String
dateOfBirth: String
userFollowers: [UserFollowing!] @connection(keyName: "byFollowers", fields: ["id"])
userFollowing: [UserFollowing!] @connection(keyName: "byFollowing", fields: ["id"])
brandFollowing: [BrandFollowing!] @connection(keyName: "byUser", fields: ["id"])
createdItems: [Item!] @connection(keyName: "byUser", fields: ["id"])
likedItems: [UserLikes!] @connection(keyName: "byUser", fields: ["id"])
orders: [Order!] @connection(keyName: "byUser", fields: ["id"])
profilePictureURL: String
}
Thanks!
question from:
https://stackoverflow.com/questions/65649297/choosing-id-as-ownedfield-in-appsync-gives-me-not-authorized-to-access-create 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…