Callidon / sparql-engine

šŸš‚ A framework for building SPARQL query engines in Javascript/Typescript
https://callidon.github.io/sparql-engine
MIT License
99 stars 14 forks source link

RDF/JS Compatibility #62

Open tpluscode opened 3 years ago

tpluscode commented 3 years ago

Is your feature request related to a problem? Please describe.

I do not find any mention of RDF/JS spec in the docs. It would be really useful if the query engine was usable with any RDF/JS DatasetCore. It's a shame that the library uses its own abstraction of the RDF model.

Describe the solution you'd like

Ideally, the usage would be something like

import { PlanBuilder } from 'sparql-engine'
// or any other RDF/JS compatible factory
import $rdf from 'rdf-ext'

const dataset = $rdf.dataset()

// the rest unchanged
const builder = new PlanBuilder(dataset)
const iterator = builder.build(query)

Describe alternatives you've considered

An adapter would also be an option like below, but I think that given the incompatibility of the graph and triple models this would not make a great solution

import { PlanBuilder, RdfjsDatasetAdapter } from 'sparql-engine'
import $rdf from 'rdf-ext'

const dataset = $rdf.dataset()
const builder = new PlanBuilder(new RdfjsDatasetAdapter(dataset))

Additional context

RDF/JS is a de-facto standard, driven by community, and widely supported. N3 is compatible, graph.js is compatible, comunica is compatible. I think it beneficiary to also use RDF/JS as the underlying model for sparql-engine

JuniperChicago commented 3 years ago

@tpluscode I have been working on this... I have made a lot of progress but I am not done. There are several intersections between types used in sparql-engine, n3, and sparqljs, and not only do the typings change as you push up to higher versions of each library, but the API's as well, so my progress has been slow. Since sparql-engine transitions between hard typings moving in and out of the pipeline and some expanded types returned by sparqljs from SPARQL* and property path queries, the algebra needed to be streamlined too. But one of the first things I did was create a namespace for sparql-engine apart from the existing `sparqljs' namespace and I have all types descending from @types/rdf-js.

Callidon commented 3 years ago

Hi,

After a long hiatus, I've finally had time to dedicate myself to Open Source again.

I agree with @tpluscode : it is a shame that sparql-engine doesn't align with the RDF/JS standard. For context, we developed this framework when RDF/JS was not in a mature state. However, since then, we have migrated some parts of the framework internals classes to work with RDF/JS natively, but we didn't finish the migration.

As of today, I'm taking care of this issue and I've started working on a complete migration from our native RDF model to RDF/JS spec. I will update this thread as progress are made, but if you have any suggestion, feel free to comment! šŸ˜„

EDIT: All work will be pushed to the develop/1.0.0_rdfjs branch

ktk commented 1 year ago

@Callidon Are you still working on that or is the issue stalled? Don't see much activity. I agree that RDFJS support would be very helpful, in that form it's not that useful as we can't integrate the library into the existing RDFJS stack.

Callidon commented 1 year ago

Hi,

I agree it is a good topic, but my current work activity doesn't allow me to focus on such side project anymore. Soi sadly, unless someone is willing to work on it, the issue is going to stale. The branch develop/1.0.0_rdjs contains a good start on what I've done until now, but realistically, I cannot allow more time to it. Sorry.

JuniperChicago commented 1 year ago

@ktk @Callidon I had worked out much of the changeover in a fork I was working on but then got slammed with other projects. I want to finish my efforts on this but cannot return to it yet. Unfortunately, this is a difficult task to accomplish incrementally, but I believe this implementation of SPARQL is one of the best I have seen in JavaScript, so I believe it is worth the effort. I cant make any promises either, but I would be willing to work with someone else if they were to invest some time too.

ktk commented 1 year ago

@JuniperChicago is that fork public? We can have a look at it @zazuko, maybe we can work it out together.

sroertgen commented 1 year ago

@JuniperChicago are you still working on it, or is the fork public as @ktk asked?

I'm also very interested in this, since I need SHACL SPARQL support in rdf-validate-shacl (e.g. see. https://github.com/zazuko/rdf-validate-shacl/issues/104).