How to replace a list in a mutation using Dgraph Cloud

Here is an alternative method which involves two mutation blocks inside a single mutation operation:

mutation EditEntryMutation(
    $title: String!
    $genres: [Genre]
  ) {
    clean: updateEntry(input: {
      filter: { title: { eq: $title } }
      remove: {
        genres: null # removes all edges
      }
    }) { numUid }
    updateEntry(
      input: {
        filter: { title: { eq: $title } }
        set: {
          genres: $genres
        }
      }
    ) {
      entry {
        genres
      }
    }
  }
3 Likes