Skip to content

Amplify DataStore: many-to-many join table not syncing when using selective sync #5454

Open
@stephenjen

Description

@stephenjen

Description

I'm experiencing an issue with Amplify DataStore in a Flutter application. The main models (Share and OperationMode) are syncing correctly, but the automatically generated join table for a many-to-many relationship (ShareOperationMode) is not syncing to the device.

Here is the schema:

type Share @model @auth(rules: [{ allow: private, ownerField: "pOwner" }]) {
  id: ID!
  // ... other fields ...
  operationModes: [OperationMode] @manyToMany(relationName: "ShareOperationMode")
  pOwner: String!
}

type OperationMode @model @auth(rules: [{allow: private}]) {
  id: ID!
  // ... other fields ...
  shares: [Share] @manyToMany(relationName: "ShareOperationMode")
}

Here is the syncExpressions:

final syncExpressions = [
  DataStoreSyncExpression(Share.classType, 
    () => Share.POWNER.eq(prefs.getString('userId') ?? '')
      .or(Share.POWNER.isOneOf(prefs.getStringList('friendIds') ?? []))
  ),
  DataStoreSyncExpression(OperationMode.classType, () => QueryPredicate.all),
];

Categories

  • Analytics
  • API (REST)
  • API (GraphQL)
  • Auth
  • Authenticator
  • DataStore
  • Notifications (Push)
  • Storage

Steps to Reproduce

  1. Add selective sync to Share model
  2. Install app
  3. Wait for sync to complete. After initial syncing, I run DataStore.close() to stop so sync expression can be loaded again to load records owned by user's friends
  4. Share and OperationMode sync correctly, but ShareOperationMode does not sync and is left with zero records.

Screenshots

No response

Platforms

  • iOS
  • Android
  • Web
  • macOS
  • Windows
  • Linux

Flutter Version

3.24.0

Amplify Flutter Version

2.4.1

Deployment Method

Amplify CLI (Gen 1)

Schema

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    datastoreIssues related to the DataStore CategoryquestionA question about the Amplify Flutter librariesto-be-reproducedIssues that have not been reproduced yet, but have reproduction steps provided

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions