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!

Nessuna risposta

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande