rubensworks / fetch-sparql-endpoint.js

A simple, lightweight module to send queries to SPARQL endpoints and retrieve their results in a streaming fashion.
MIT License
22 stars 13 forks source link

Support for RDF-star? #60

Closed benjaminaaron closed 1 year ago

benjaminaaron commented 1 year ago

When fetching statements about statements (RDF-star), they appear like this:

Screenshot 2023-03-02 at 09 51 04

In the GraphDB the respective triple looks like this:

Screenshot 2023-03-02 at 09 51 42

My code to fetch the bindings is the following:

import { SparqlEndpointFetcher } from "fetch-sparql-endpoint";
const sparql = new SparqlEndpointFetcher();

async function fetch() {
  const bindingsStream = await sparql.fetchBindings('http://localhost:7200/repositories/dev', 'SELECT * WHERE { ?s ?p ?o }')
  bindingsStream.on('data', (resultRow) => {
    console.log(resultRow)
  });
}

await fetch()

Is there a way to map this long identifier in urn:rdf4j:triple to a triple? Like a hash-sum or something like this 🤔

benjaminaaron commented 1 year ago

Ohh, it's base64 encoded! I just decoded it correctly to: <<<http://dev.de/default#Projects> <http://dev.de/default#hasProject> <http://dev.de/default#AkteX>>> 👍

rubensworks commented 1 year ago

The underlying SPARQL results parsers of this library do already support RDF-star and SPARQL-star as of recently. So if your querying from an engine that adheres to the RDF-star spec, then this lib should be able to handle it.

It looks like rdf4j uses a non-standard serialization approach for nested triples, so this library will not be compatible with it unfortunately.

benjaminaaron commented 1 year ago

I see, thanks. Surprising that the GraphDB engine doesn't support this yet. Maybe they will in a future release.