Do Type System in dgraph provide type safety?

mutation

(Kundan Kumar) #1

What are the use cases of type system if it is not providing type safety?
This is our schema:

 type person {
   name: string
   age:int
}
name:string@index(exact)@lang .
age:int@index(int) .

Here is the mutation:

{
  "set":
  {
    "name":"person1",
    "age": 20,
    "dgraph.type": "person",
    "address":"myAdress"
}
}

The above mutation adds a node successfully of type person with a predicate address which is not declared in our type system. So our concern is that the type system is only used to categorize the nodes and query them based on their type or does it also provide type safety?


(Michel Conrado) #2

As far as I can remember, the Type System came to make entity handling easier.

TS is not Type Safety, you can add predicates and edges that are not defined in type. In the future, there could be a restriction on this. But today TS is focused on determining entities and is essential for the query functions.

Cheers.