Mutate a data and retrieve the result in the same request

For instance, I would like to add an element to a list and in the same request retrieve the new length of the list.
Is is possible ?

You can use Upser Block - In the response payload of UB query, it comes to a field called "q" or the same name you given to the query. So, after the mutation, it will return the query with the values changed. That can be used for your use case.


According to the documentation:

Execution of an upsert block also returns the response of the query executed on the state of the database before mutation was executed

In my example, I would like to retrieve the lenght of the list after the element was inserted.

humm, is true.

I thought this had resolved, but it looks like you will have to make a second request. Cuz It is not supported.

Ok thank you for your answer.

Do you know if this feature is planned to be implemented ?

That’s the idea behind this issue

Ok !

And just to be sure, given that dgraph is Sequentially Consistent if I perform a read request just after a mutate request, I am sure to retrieve the updated data, that’s right ?


BTW I have reformulated the issue

Perfect, thanks a lot !