Run a mutation with a external id

I am trying to use a external id instead of default UID for a subject of a N-quad record.

According to the docs: External-ids:

I should use a_fixed_identifier as the subject of a N-quad record, so I try to mutate the database like this:

# <lianlian>: the fixed_identified that I want to use as a external id
# <type>: the predicate
# "product": a value object
curl -s -XPOST localhost:8080/mutate/25 -d '
  set {
    <lianlian> <type> "product" .

However, I got a error response:

  "errors": [
      "code": "ErrorInvalidRequest",
      "message": "strconv.ParseUint": parsing \"lianlian\": invalid syntax"
  "data": null

Seems like Dgraph tried to parse the External ID as a integer which causes the error?

Is it a wrong usage of external id?


In the documentation says:

As of version 0.8 Dgraph doesn’t natively support such external IDs as node identifiers. Instead, external IDs can be stored as properties of a node with an xid edge. For example, from the above, the predicate names are valid in Dgraph, but the node identified with <> could be identified in Dgraph with a UID, say 0x123 , and an edge

Dgraph will never identify<lianlian> as BlankNode or something valid.
As you can see at
In the RDF format used by Dgraph the Entity will always represent a standard Dgraph entity identification. Be it a BlankNode or a UID (eg: 0x1a35).

This part of the documentation is teaching how to use this xid as part of the Node itself. Not as a RDF markup identifier.

In other words, it is transforming this
_: userA <> <>.
into a node with UID ==> “0x123” or
<0x123> <xid> "".

It transforms the <> into a Dgraph Node
<0x123> <xid> "".

I got it.

After reading this carefully, I found that: it is the Dgraph’s input language RDF supports this form of external id: <a_fixed_identifier> <predicate> literal/node, which I misunderstood it as the form of Dgraph that it supports.

Thanks a lot.

1 Like