Generated update resolver should allow for an array of UpdateXXXInput arguments

In GraphQL, there’s a bit of inconsistency with the semantics of the resolvers that are generated for each entity.

The addXXX resolver allows for multiple entity payloads to be specified as arguments, and for multiple entities to be created simultaneously.

Likewise, the deleteXXX resolver allows for multiple ids or a filter to delete multiple entities simultaneously.

The updateXXX resolver, however, only allows for the same mutation fields to be applied to matching entities.

It would be more useful if the input arguments for updateXXX resolver would be [UpdateXXXInput!]!, as it is for add.

In this way, I could create a mutation that allows for the batch adding, updating or deleting of entities in many areas of a graph atomically in a single request.

@MichelDiz can you tag this GraphQL.

@martaver, I like the idea. I had something like this with my custom graphql api (not dgraph). The only différence would be that each update clause would have to have its own filter most likely. Here is how I implemented this in my api and how it might look one way with dgraph concept:

updatePerson(id:["0x1","0x2","0x3"] patch:[{name:"Bob"},{name:"Sally"},{age:3}]

in concept this sets:

0x1 <Person.name> "Bob" .
0x2 <Person.name> "Sally" .
0x3 <Person.age> "3" .

Of course this would add some processing complexity to make sure that the inputs are formed correctly

Done, hey, is this an issue or something else? I’m not following well the topic.

I think more of a question/feature request. A way to update a set of data with their own individual updates in q single update. Right now you can update a set with the same patch but no way to do a patch for each.

2 Likes

Hey @martaver

Thanks for your input. Your point is valid, we’ll discuss this with the team and see if we can support this.

Awesome - would really appreciate that!