On 19/10/2019 09:27, Mike Bendorf wrote:
Hi,
I work for Minerva Intelligence and I have a question about GraphQL. I
have been able to run a few queries on our endpoint to return basic
information from our taxonomies for ex.
|
query{
conceptSchemes{
label
}
}
|
which shows me every Concept Scheme, indicating endpoint is active.
But instead I would like to do the following:
- Return all Concepts for an *Specific Scheme*
You can access a specific resource with the (uri: "...") argument, e.g.
{
conceptSchemes(uri:
"http://topquadrant.com/ns/examples/geography#Geography") {
label
}
}
Now, getting the root concepts is simple
{
conceptSchemes(uri:
"http://topquadrant.com/ns/examples/geography#Geography") {
label
hasTopConcept {
label
}
}
}
while getting all concepts that are (recursively) children of the root
concepts is harder without some extra adjustments. This solution here
would give you the first level of children
{
conceptSchemes(uri:
"http://topquadrant.com/ns/examples/geography#Geography") {
label
hasTopConcept {
label
narrower {
label
}
}
}
}
yet GraphQL isn't designed to return arbitrary nesting, as the structure
of the query needs to reflect the structure of the resulting JSON. If
you want to get a "flat" list of every concept under a certain schema,
then you'd either need to extend the GraphQL schema by a new field that
would allow you to flatten the structure, or fall back to SPARQL. In
SPARQL this would be
SELECT DISTINCT ?concept ?label
WHERE {
<http://topquadrant.com/ns/examples/geography#Geography>
skos:hasTopConcept ?topConcept .
?concept skos:broader* ?topConcept .
BIND (ui:label(?concept) AS ?label)
} ORDER BY ?label
which is possible because SPARQL has a * operator that recursively walks
a property.
To ask a similar query in GraphQL, the schema can be extended to create
a similar "flattened" field such as narrowerTransitive, which would be
inferred using a sh:values rule. In fact, the next TopBraid release will
have such a field, and it's defined in SHACL using
skosgeneric:Concept-narrowerTransitive
rdf:type sh:PropertyShape ;
sh:path skos:narrowerTransitive ;
sh:description "Gets the concept plus all narrower concepts,
recursively." ;
sh:name "narrower transitive" ;
sh:node skosgeneric:Concept ;
sh:nodeKind sh:IRI ;
sh:values [
sh:path [
sh:zeroOrMorePath [
sh:inversePath skos:broader ;
] ;
] ;
] ;
.
If this type of query is what you need, I could prepare a patch for you.
- Return *Broader or Narrower for an Specific Concept and for an
Specific Scheme*
As I said above, you can access a specific concept or scheme using
uri:"...". For example
{
concepts (uri: "http://topquadrant.com/ns/examples/geography#Germany") {
label
narrower {
label
}
broader {
label
}
}
}
More documentation can be found in the Tutorial link near the GraphQL
link in TopBraid EDG, or online at
https://www.topquadrant.com/graphql/graphql-queries.html
HTH
Holger
This is a new installation of TopBraid and we have just added some
Taxonomies through the Import RDF File option.
Very much appreciated,
Mike
--
You received this message because you are subscribed to the Google
Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/topbraid-users/91ebb5d5-be47-4302-b67e-3e4075cc4945%40googlegroups.com
<https://groups.google.com/d/msgid/topbraid-users/91ebb5d5-be47-4302-b67e-3e4075cc4945%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google Groups "TopBraid
Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/topbraid-users/708fda99-d29e-0a2d-b8f5-22466e7eb4ec%40topquadrant.com.