Predicate to create dgraphtype?

Is there any way we can have predicate to create dgraph type like we create fields ? this will help do create as many type without having to add { } brace and adding new lines

You may use dgraph.type predicate.
For more information : https://dgraph.io/docs/query-language/type-system/#setting-the-type-of-a-node

Hi @dgandhi17,

would you mind to reformulate your question? Feels like you know that we need the dgraph.type, but you wanna do something else that I can’t see what it is for sure.

A predicate is a synonym for edges. Edges don’t have anything special other than being connections and store information. Edges can’t perform operations if is that what you are talking about.

I assume you are using JSON mutations right?

Please, clarify so we can help.

Cheers.

It was more of a dynamic type creation but I guess below will help

{
  set {
    _:a <dgraph.type> "Animal" .
  }
}

but once I create this I can’t see the type in the type list under ratel console

1 Like

Yeah, Dgraph can’t create DTypes based on user usage. That would require some dark magic (with AI?). So, you have to define your mutations manually.

I think you won’t see this cuz it is a system predicate - so you can modify it. You can see tho, via query. e.g:

{
   q(func: eq(something, "else")) {
    name
    <dgraph.type>
  }
}