Query and mutate in one request

I’m wondering if there’s a way to perform a query and mutation in the same query. If I remember correctly in older versions (before transactions were implemented) we were able to run queries that collected results and performed mutations. Forgive the syntax below but it demonstrates briefly what I’m looking to accomplish:

   var(func: has(Postings)) {
       Postings as uid
   mutation {
      <0x938574> <Result> uid(Postings)

Basically want to collect a list of UIDs and make edges from there.


1 Like

In transactions, we had removed the query + mutations mix, due to that logic getting overly complex. I think we’ll reintroduce this functionality once we support Cypher, which has directives for updates.

Is there an easy way to do so with a transaction or will I have to a) query all the UIDs get the result back, b) within my application structure the mutation and then c) commit the whole transaction?

Would there be ANY way to avoid sending the UIDs back to my application and mutate them directly to replicate the old query + mutation mix?

There is no way right now, though we will probably introduce something soon.

introducing Cypher would make this product 1M times better. GraphQL+ just sucks

just like SQL .
update somenode set something=somevalue where something is cool

I do want to do mutation with filters .

i tried to use db to save uids that dgraph returned and you can query uid from db. you also can use this db to provide a service to search uid, before you insert data to dgraph you can try to ask the db if this data exist already in dgraph

We introduced upsert block last year, which can achieve this functionality now. It is documented here:


1 Like