Handling internal Type/Predicate

Hey @core-devs,

At present, we have 4 internal types (3 related to ACL, and one for GraphQL):

  • User
  • Group
  • Rule
  • dgraph.graphql

and all these types are composed of some predicates like dgraph.acl.rule or dgraph.graphql.schema.

The problem with current implementation is that if someone wanted to create a type called User in their application, then it would result in collision with our internal ACL User type, and their queries may not work as expected. Specifically, in GraphQL this results in an issue, as queries are performed using type filter.

To overcome this problem, we are going to prefix dgraph’s internal types with dgraph.; so, ACL User will become dgraph.User (more accurately, we have renamed it as dgraph.type.User), while dgraph.graphql remains as is. Same goes for other internal types which are not namespaced. All the current internal predicates are already prefixed with dgraph. and, then we won’t allow anyone to create types/predicates which start with dgraph.; so, this basically reserves dgraph. as the namespace for any internal types/predicates used by dgraph. This change is supposed to go as a breaking change in 20.07 release.

On a side note, we also have this issue regarding export, where exporting internal predicates causes live loading to fail (specifically, dgraph.graphql.schema). I feel both these issues are somehow related a bit.

I am writing this post in order to notify everyone regarding this breaking change. So, in future we create internal types/predicates in dgraph. namespace.
Any suggestions/comments regarding this or thoughts about conflicts resulting from this are welcome.

1 Like

Martin has a PR for handling the dgraph.graphql.schema issue separately by not exporting it and instead writing out the GraphQL schema file. That seems like an OK approach for now. For the other reserved predicates as you have figured out we should not allow altering their schema or creating them. Mutating them would be allowed. Its good that we are applying a blanket rule that all dgraph. predicates and types are reserved.