consider for example a Comment type as discribed below:
type Comment @model @auth(rules: [
{ allow: public, operations: [read]}
{ allow: owner }
]) {
id: ID!
text: String!
}
my question is how can an owner filter his own comments, is there any implicit relation that we can use between Apmlify Auth & Amplify api, otherwise I will add a new field in the schema
cognitoID @index(name:'byCognitoID', queryField: "commentByCognitoID")
thanks
You have to create the field to have the relationship:
type Comment @model @auth(rules: [
{ allow: owner }
{ allow: public, operations: [read]}
]) {
id: ID!
text: String!
owner: String @index(name: "commentsByOwner", queryField: "commentsByOwner")
}
Then use:
amplify push
Now it will create your queries and you should see one named commentsByOwner.
I realize this is still creating a new property in your schema, but I believe this is the only way to do this for now without removing the public auth rule.
https://docs.amplify.aws/cli-legacy/graphql-transformer/auth/#field-level-authorization
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.