outcaste-io / issues

File issues here across all public Outcaste Repositories
Apache License 2.0
6 stars 0 forks source link

Feature - Update Multiple #23

Open jdgamble555 opened 2 years ago

jdgamble555 commented 2 years ago

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