dgraph icon indicating copy to clipboard operation
dgraph copied to clipboard

Feature Request - GraphQL Update Multiple

Open jdgamble555 opened this issue 3 years ago • 0 comments

Dgraph Allows you to update many items at once, ONLY if you update with the same values. This is a problem for simple updates.

Let's say I want to update two different posts with ids 0x1 and 0x2 with values title: 'outcaste' and title: 'dgraph'. The only way to do this currently is with two updates using alias like so:

mutation {
  post1: updatePost(input: {
    filter: { id: '0x1' },
    set: { title: 'dgraph' }
  }) {
  ...
  },
  post2: updatePost(input: {
    filter: { id: '0x2' },
    set: { title: 'outcaste' }
  }) {
  numUids
  }
}

However, I should be able to do just this:

mutation {
  updatePost(input: [{ 
    filter: { id: '0x1' },
    set: { title: 'dgraph' }
  }, {
    fitler: { id: '0x2' },
    set: { title: 'outcaste' }
  }]) { numUids }
}

The difference here is that the input should accept an array like so:

updateType(input: [UpdateTypeInput!]!) UpdatePayload

This would work EXACTLY like the add works, and would save some time trying to write complex mutations.

This is just a simple example, but complex examples really can prove how important this is.

Please see this discuss post for more info.

J

jdgamble555 avatar Aug 26 '22 00:08 jdgamble555