With amplify and graphql, updating array field in table appends update array to existing table array rather than replacing it

Viewed 300

I am using GraphQL API in an amplify project WITHOUT local datastore and conflict resolution off. I have the following schema:

type SomeObject
  @model
  @auth(
    rules: [
      { allow: owner, operations: [create, delete, update] }
    ]
  ) {
  id: ID!
  version: Int!
  owner: String
  name: String
  media: [Media]
}

type Media {
  id: ID!
  owner: String
  mediaType: String!
  order: Int!
  createdAt: String
  updatedAt: String
}

When I perform an Amplify.API.mutate(request: .update ... on SomeObject, instead of replacing the media field with the new array I pass it appends the new array I pass to the existing array in the table. I am using the iOS framework but from what I can see online this behavior is similar in other frameworks.

I am not using local Datastore and so conflict resolution is off so that solution that worked for others is not the solution for me.

Has anybody found a solution for this?

0 Answers
Related