Schema Queries

How to do schema queries using WOQL with TerminusDB and TerminusCMS data products
To use this How-To, first clone the Star Wars demo into your team on TerminusCMS. You will then have full access to the data needed for this tutorial

Finding elements from the schema.

In order to query the schema, you can use graph arguments to WOQL. TerminusCMS stores each branch as a pair of graphs, an instance graph and a schema graph.
We can specify the graph by passing it as an argument to the quad word.
To find all classes in the schema for instance, we can write:
let v = Vars("cls");
quad(v.cls, "rdf:type", "sys:Class", "schema")
This results in:
The @schema denotes the default schema prefix, and makes it clear that this identifier lives in the schema namespace rather than the data namespace.
We can also use the typical triple word if we use from to set our default graph to schema instead of instance.
let v = Vars("cls");
.triple(v.cls, "rdf:type", "sys:Class")