This is an idea for how SHACL AF Node Expression can be used to annotate a hydra search template so that values coming from the request query string would be transformed to SPARQL patterns an injeced into the resulting query
The collection resource <shapes>
supports a targetNode
query string parameter which should be translated to a SPARQL union like below. The $this
token will represent each collection member (instance of shape). For example, when requesting shapes?targetNode=foobar
, the generated patterns could be:
{
# query the target node directly
$this sh:targetNode <foobar>
}
UNION
{
# or find shapes which target foobar's classes
$this sh:targetClass/^rdf:type <foobar> .
}
This would be equivalent to this filter shape
[
sh:filterShape [
sh:property [
sh:path [
sh:union (
[ sh:path sh:targetNode ]
[
sh:nodes [ sh:path sh:targetClass ] ;
sh:path [ sh:inversePath rdf:type ] ;
]
) ;
] ;
sh:hasValue <foobar> ;
] ;
] ;
] .