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!

답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠