AWS Amplify Android app with a schema with multiple authentication rules

0

Hello everyone! I'm working on a project with AWS Amplify in a Kotlin native Android app. I am facing an issue with Authentication and DataStore when my model has multiple authentication rules, basically with write/read/sync permissions to the owner and read/sync permissions to all other signed users. The problem is that the signed users, which are not the owners, are not receiving updates when they try to observe queries to get realtime updates.

Maybe it's because the real model has other fields automatically created by Amplify, such as _version and _lastChangedAt, and because of that, the subscription is not able to complete to receive realtime updates. The "non owners" can read, but can't receive updates after an operation to observe queries

If you have any tip, please let me know.

This is my schema.graphql file:

type Post @model
@auth(rules: [
  { allow: owner, ownerField: "email", identityClaim: "email" }
  { allow: private, operations: [read] }
])
{
  id: ID!
  @auth(rules: [
    { allow: owner, ownerField: "email", identityClaim: "email" }
    { allow: private, operations: [read] }
  ])
  email: String!
  @index(name: "byEmailAndCategory", sortKeyFields: ["category"],
    queryField: "postsByEmailAndCategory") 
  @index(name: "byEmailAndCreatedAt", sortKeyFields: ["createdAt"],
    queryField: "postsByEmailAndCreatedAt") 
  @auth(rules: [
    { allow: owner, ownerField: "email", identityClaim: "email", operations: [create, delete, read] }
    { allow: private, operations: [read] }
  ])
  createdAt: AWSDateTime!
  @auth(rules: [
    { allow: owner, ownerField: "email", identityClaim: "email" }
    { allow: private, operations: [read] }
  ])
  title: String!
  @auth(rules: [
    { allow: owner, ownerField: "email", identityClaim: "email" }
    { allow: private, operations: [read] }
  ])
  content: String!
  @auth(rules: [
    { allow: owner, ownerField: "email", identityClaim: "email" }
    { allow: private, operations: [read] }
  ])
  category: PostCategory!
  @index(name: "byCategoryAndCreatedAt", sortKeyFields: ["createdAt"],
    queryField: "postsByCategoryAndCreatedAt")
  @auth(rules: [
    { allow: owner, ownerField: "email", identityClaim: "email" }
    { allow: private, operations: [read] }
  ])
  updatedAt:AWSDateTime!
  @auth(rules: [
    { allow: owner, ownerField: "email", identityClaim: "email" }
    { allow: private, operations: [read] }
  ])
}

enum PostCategory {
  FOOD
  TECH
  TRAVEL
  PET
  NEWS
}

The behavior without the auth rules on each field is the same. Thank you very much!

已提问 4 个月前139 查看次数
没有答案

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则