sparna-git / Sparnatural

Sparnatural : Typescript visual SPARQL query builder for knowledge graphs, configurable with SHACL
http://sparnatural.eu
GNU Lesser General Public License v3.0
206 stars 34 forks source link

Alternative backend? #532

Open pchampin opened 9 months ago

pchampin commented 9 months ago

I would be super interested in building a Solid application using Sparnatural. The only problem is that Sparnatural currently relies on the existence of a SPARQL endpoint (i.e. a server speaking the SPARQL protocol), while in Solid, servers expose simple RDF "files".

Would it make sense for a future version of Sparnatural to use a modular backend, which could use SPARQL endpoints, "static" RDF resources, and possibly other sources of data? Comunica would look like an interesting candidate, as it already supports different kinds of sources.

In particular, Comunica has a module for querying data on Solid pod, taking into account authentication and the fact that data can be distributed across multiple resources: https://github.com/comunica/comunica-feature-solid

tfrancart commented 9 months ago

2 ideas come to my mind:

  1. The easiest, and not-so-far possibility, would be to fetch the RDF document, load it in an in-memory triplestore on the client side (in the browser), and execute the SPARQL query on it. I call this "serverless integration" and there is an issue on this at #482 (although not described at all :-) ) - the in-memory implementation I tested with is https://github.com/Callidon/sparql-engine, and I have a working version. I suspect, although I am not sure, that Comunica works the same way : resolve an RDF response from a SOLID server, dealing with authentication, etc, and then querying it locally.
  2. Alternatively, we could generate something else than SPARQL, if a custom query language is necessary.
tfrancart commented 9 months ago

Actually, the demo of Sparnatural working purely on local files using browser-side SPARQL engine (https://github.com/Callidon/sparql-engine) is here : https://github.com/sparna-git/sparnatural.eu/blob/main/demos/demo-local/index.html#L495

pchampin commented 4 months ago

I suspect, although I am not sure, that Comunica works the same way : resolve an RDF response from a SOLID server, dealing with authentication, etc, and then querying it locally.

Not exactly. This would actually depend on the underlying sources. As far as I understand, Comunica is able to forward (part of) the query to the a SPARQL endpoint, split it into triple patterns if the source is a TPF endpoint. It also has a query-traversal feature, that allows it to retrieve data from new sources as partial results are discovered...

Alternatively, we could generate something else than SPARQL

This would not be required for Comunica, which accepts SPARQL queries as its input, and does all the magic (decomposing it, retrieving data from different sources...) behind the scene. See https://comunica.dev/docs/query/getting_started/query_app/

tfrancart commented 4 months ago

Comunica has browser-ready packages at https://github.com/rdfjs/comunica-browser This could be integrated via the customization object : http://docs.sparnatural.eu/Javascript-integration.html#sparnatural-customization-object-reference