I created a GraphQL API using AWS' Amplify. In the schema, I have a Comment model that looks like this:
type Comment
@auth(rules: [{ allow: owner }, { allow: private, operations: [read] }, { allow: public, operations: [read] }])
@model
@key(name: "byAuthor", fields: ["authorID"])
@key(name: "byPost", fields: ["postID"]) {
content: String!
createdAt: AWSDateTime!
id: ID!
owner: String
postID: ID!
updatedAt: AWSDateTime!
}
This gives the owner permission to create, read, update, and delete, and restricts unauthenticated/authenticated-non-owner users to read-only. This works as expected; however, the owner can update the ownerField's value, essentially attributing the comment to another user...which is a no-no. To prevent this, I tried using field-level permissions (see below); however, that doesn't appear to be stopping the update.
...
owner: String @auth(rules: [{ allow: owner, operations: [ create ]}])
...
Is there something I'm missing? Any help is much appreciated--thank you!