Run upserts

Moved from GitHub ratel/119

Posted by pepoospina:

How can run an upsert from Ratel?

{
  upsert {
    query {
      v as var(func: eq(email, "user@company1.io"))
    }

    mutation {
      set {
        uid(v) <name> "first last" .
        uid(v) <email> "user@company1.io" .
      }
    }
  }
}

paulftw commented :

@mangalaman93 how should it supposed to work via HTTP?
Currently for the upsert above Ratel sends /mutate with content-type application/rdf but server returns Error while lexing <query above> at line 2 column 10: Invalid character '{' inside mutation text

mangalaman93 commented :

The outermost braces are causing the issue just remove them.

upsert {
    query {
      v as var(func: eq(email, "user@company1.io"))
    }

    mutation {
      set {
        uid(v) <name> "first last" .
        uid(v) <email> "user@company1.io" .
      }
    }
  }

paulftw commented :

Seems like removing brackets will solve the issue.
Closing the github bug for now.

@pepoospina please feel free to reopen if you still have problems sending an upsert mutation via Ratel

onkarbanerjee commented :

Using uid(v) as the object in the mutation doesn’t work though.