Dgraph DQL Tour
Adding schema - mutating schema
As we saw in an earlier lesson, Dgraph stores a schema describing the types of predicates.
When we want to add new data to an existing schema, we can just add it. But if we want to add new data in a new schema we have two choices
- Add the data and let Dgraph work out the schema, or
- Specify a schema and then add the data
Dgraph can work out the schema just fine. Functions at query root can only be
applied to indexed predicates and for that we need to specify the schema.
Comparison functions at the query root level (aka
func:) can only be applied
on indexed predicates, which are added by annotating the predicate definition on
the schema. Since v1.2, comparison functions can now be used on
directives even on predicates that have not been indexed.
Alter schema to define data types and to add indexes.
Run to alter schema. The index allows applying filter functions, such as searching for all companies that participate in a particular industry.