I’m trying to use sync expression to limit the amount of data users need to sync from the cloud, but am unable to do so if a single sync expression is dependent on two different models. Here’s the schema in question:
type Activity @model @auth(rules: [{ allow: private, ownerField: "pOwner" }]) {
id: ID!
date: AWSDateTime!
action: ActivityAction!
pOwner: String!
}
type Friend @model @auth(rules: [{ allow: owner, ownerField: "pOwner" }{ allow: private, operations: [read] }]) {
id: ID!
profileID: ID @index(name: "byProfile", sortKeyFields: ["id"])
profile: Profile @belongsTo(fields: ["profileID"])
activities: [Activity] @hasMany(indexName: "byFriend", fields: ["id"])
pOwner: String!
}
Users’ activities are stored in the Activity model. Users can friend each other, and those friend relationships are stored in Friend. In my app, users can see their friends’ activities too.
How would I go about structuring my sync expressions so that a user only sync their own activities and also those of their friends’?