Query to show all resources associated to a concept


I want to show all resources attached to an entity. I want this information without creating any instances like at a schema level. Following query does not work as I think has in the Match queries only work for instances

match $x sub entity; $x label "student"; $x has $y; $y sub resource

Is there some other query that can help here ?



Just to confirm that I understand what you are asking: you would like to find out which resources can be attached to an entity as defined in your ontology. Unfortunately there is no straightforward way to query this information right now. We are still trying to resolve the semantics of the has syntax to make this easier in the future.

To achieve your task you will have to use graql shell with the implicit types flag

graql.sh -i

or enable implicit types in java

((GraknGraph) graph).showImplicitConcepts(true);

This allows you to query the relationships we add to the graph to support the has syntax. Once this is done you can execute this query:

match $a label student; $a plays $b; $c relates $b; $c relates $d; $b != $d; $e plays $d; $e sub resource; select $e;

and you will get the resource types that can be attached to the student entity type. The query essentially fetches the roles and relationships that a student can take part in and then returns the resources that can play different roles in the relationships.