DAG in pydgraph

What Dgraph client (and version) are you using?

(put “x” in the box to select)

  • Dgo
  • PyDgraph
  • Dgraph4J
  • Dgraph-js
  • Dgraph-js-http
  • Dgraph.NET

Version: 21.03.0

What version of Dgraph are you using?


What I want to do

Using pydgraph, I want to store a Directed Acyclic Graph in dgraph, where I am storing a predecessor ID to point from one node to its predecessor.

Is there a good way to control the uid:s assigned to my nodes? Preferably I would want to manually set my own uid:s, but as I understand it it is done automatically.

As it stands right now, it seems like I would have to fetch the data of the predecessor node to see its uid. The graphs I am handling can be quite large, so this isn’t really feasible to do.

Side note: Is there a way in pydgraph to define inverse?
I would like for my schema to look like what is defined below

<taskID>: string .
<name>: string @index(exact, term) @lang .
<problemID>: string .
<predID>: [uid] @inverse(field: "succID") .
<succID>: uid @inverse(field: "predID") .

type <Task> {

But then I get the error:
while lexing \n\n : string .\n : string index(exact, term) lang .\n : string .\n : [uid] inverse(field: “succID”) .\n : uid @inverse(field: “predID”) .\n\n type {\n taskID\n name\n problemID\n predID\n succID\n }\n at line 6 column 44: Invalid schema. Unexpected “”

Thanks very much if anyone can help me!

Yes. It is call “UID Leasing”. https://dgraph.io/docs/deploy/dgraph-zero/#endpoints
e.g. with /assign?what=uids&num=100 you can allocate 100 UIDs for your use case.

You can also use the Admin GraphQL API https://dgraph.io/docs/graphql/admin/#admin

 Lease UIDs, Timestamps or Namespace IDs in advance.
 assign(input: AssignInput!): AssignPayload

	type AssignedIds {
		The first UID, TIMESTAMP or NAMESPACE_ID assigned.
		startId: UInt64
		The last UID, TIMESTAMP or NAMESPACE_ID assigned.
		endId: UInt64
		TIMESTAMP for read-only transactions.
		readOnly: UInt64

Inverse is a GraphQL feature. Not DQL. In DQL you have reverse.

Remove this. It is not supported.

Cuz it is not supported.