Wed Sep 6

  • learnt about the following dgraph mutation today.
mutation {
  set {
    _:cat <name> "Millhouse" .
    _:cat <color> "Black" .
    _:cat <age> "0.7"^^<xs:float> .

    _:human <name> "Kaley" .
    _:human <age> "22"^^<xs:float> .
    _:human <favorite_food> "chocolate" .

    _:human <owns> _:cat .
  }

  schema {
    name: string @index .
  }
}

** mutation is for changing data in the graph or changing the graph schema ** set is for mutations that insert triples into the graph ** the strange syntax ^^<xs:float> is apparently how a value is typed as a float...

  • about dgraph triples ** triples are specified according the W3C standard https://www.w3.org/TR/n-quads/[RDF N-Quad format] ** their format is <subject> <predicate> <object> . subject is always a node. object is either a node or a value (also know as literal). predicate is a directed edge from subject to object, the value here is the edge name. A given edge must always point to a consistent type (in effect the edge type). A . is present because of the spec apparently less because of need on dgraph side https://dgraph.slack.com/archives/C13LH03RR/p1504754827000129[link]

  • blank node is written _:identifier in a mutation. Used to identify a node within a mutation. Outside a particular mutation the identifiers have no existance. _ will be replaced by dgraph with an automatically generated 64bit unique ID. These IDs are available in the mutation return result:

{
  "data": {
    "code": "Success",
    "message": "Done",
    "uids": {
      "foo": "0x2712",
      "qux": "0x2713",
      "bar": "0x2714"
    }
  }
}
mutation {
  schema {
    foo {
      bar: string .
    }
  }
}

but this would work:

mutation {
  schema {
    bar: string .
  }
}