-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Not exactly sure whether this best belongs here, in the comunica repo, or possibly even the LDflex repo, depending on how you want to go about solving the issue.
When using LDflex to query over a SHACL constraint in a repo we are hosting - I want to use the following pattern.
const { PathFactory } = require('ldflex');
const { default: ComunicaEngine } = require('@ldflex/comunica');
const { namedNode } = require('@rdfjs/data-model');
// The JSON-LD context for resolving properties
const context = {
"@context": {
"@vocab": "http://xmlns.com/foaf/0.1/",
"friends": "knows",
"label": "http://www.w3.org/2000/01/rdf-schema#label",
"property": "http://www.w3.org/ns/shacl#property",
"path": "http://www.w3.org/ns/shacl#path"
}
};
// The query engine and its source
const queryEngine = new ComunicaEngine('http://rsmsrv01.nci.org.au:8890/sparql');
// The object that can create new paths
const path = new PathFactory({ context, queryEngine });
async function showShape(shape: any) {
console.log(`This person is ${await shape.label}`);
for await (const property of shape.property) {
console.log("path associated to property", `${await property.label}`)
}
}
const myShape = path.create({ subject: namedNode('http://example.org/humanWikidataShape') });
showShape(myShape);
Because each property in the shape is a blank node property
is a blank node so calling await property.label
cases the query
SELECT ?label WHERE {
<urn:comunica_skolem:source_0:nodeID://b12796> <http://www.w3.org/2000/01/rdf-schema#label> ?label.
}
to be issued by LDflex.
With the current engine setup this query eventually gets passed through the replaceBlankNodes
function within ActorRdfResolveQuadPatternSparqlJson
and hence the query that actually gets sent by the engine is
SELECT ?nodeID://b12796 ?label WHERE { ?nodeID://b12796 <http://www.w3.org/2000/01/rdf-schema#label> ?label. }
This has invalid variable names so the SPARQL endpoint returns an invalid variable name error
Error: Invalid SPARQL endpoint (http://rsmsrv01.nci.org.au:8890/sparql) response: Bad Request (400)
at AsyncIteratorJsonBindings.fetchBindingsStream (/home/jesse/Documents/github/on2ts-dev/on2ts/node_modules/@comunica/actor-rdf-resolve-quad-pattern-sparql-json/lib/AsyncIteratorJsonBindings.js:56:19
But more to the point; the blank nodes should not be changed to variables here. I'm guessing either the query engine config needs to be fixed here; there is some bug in comunica engine.