LDflex over In-Memory RDF Data
See original GitHub issueHi,
Is there a way to use the proxying approach over in-memory data so that the await is no longer necessary? it feels quite clumsy in cases where all data RDF data is locally available anyway.
For my use case I just want to import static RDF files (or fetch an RDF graph in batch from an endpoint), and then have a resource-centric view over it (in contrast to triple based ones), and finally have a JavaScript proxy over it that exposes outgoing and ingoing triples as virtual JSON attributes - in the simplest case by just matching magic JSON atttributes to RDF local names.
To illustrate it conceptually step-by-step:
# expample.ttl
@prefix eg: <http://www.example.org/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
eg:Foo eg:relatesTo eg:Bar .
eg:Bar rdfs:label "Bar" .
// Load a string or JSON representation of a batch of RDF from whatever source - possibly async
var stringOrJson = loadRawRdf("example.ttl")
// If I am not mistaken, import only works for JSON, so only for json-ld we could do "import data from 'example.jsonld'"
// Make the RDF string/json accessible using a proper RDF-API
var model = makeRdfModel(stringOrJson)
// Get a resource centric view
var resource = rdfModel.getResource("http://www.example.org/Foo")
// Now comes the proxy magic:
var fooProxy = makeRdfProxy(resource)`
// In general, properties in RDF are multi-valued, so in general it maps to an (unordered) array view
console.log(fooProxy.relatesTo[0].label)
// Output: Bar
// On the array proxy, try to delegate all calls to element [0] if no array index is used
console.log(fooProxy.relatesTo.label)
// Output: Bar
The main benefit is, that one can then really create fuzz free HTML views just like:
<template>
<h1>Hello {foo.relatesTo.label}</h1>
</template>
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Who says using RDF is hard? - Ruben Taelman
A brief overview on RDF and Linked Data development in JavaScript. ... The easiest way to create an RDF graph is using an...
Read more >Example code to read an in-memory JSON-LD document? #81
I think I've managed to get it read in through JsonLdParser , created a ComunicaEngine passing in the parser as the data and...
Read more >Is RDF "hard"? - Solid Community Forum
After I mulled on this for awhile, I emotionally came around to the notion that while this is harder than usual, it's easier...
Read more >LDflex: a Read/Write Linked Data Abstraction for Front-End ...
This article discusses the design, implementation, and embedding of LDflex, a domain- specific language that exposes the Web of Linked Data through ......
Read more >RdfAndSql - W3C Wiki
RDFox - Highly scalable in-memory RDF triple store supporting SPARQL queries and direct mapping of SQL data into RDF. SPARQL Across Federated Sources....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hm, so the datamodel and dataset API seem very synchronous to me. Are other components actually using this model? Especially, can the existing parsers output a dataset ? Well, one can always assemble from a set of async quad events.
So having an interface for a set of quads with a synchronuous match(g, s, p, o) method is already a good start - although I am a bit worried not seeing a graph abstraction (triples). Because typically one navigates from a node within a graph to other nodes within the graph - unless one explicitly creates a union-graph (again a graph) view over all named graphs in the dataset. So my impression is, that there is a fundamental interface missing 😦
W.r.t async calls, if they are used to fetch graphs or datasets at once, then there is no issue, because once it is placed as a whole into the (view) model, the view can update itsel synchronously afterwards (I am thinking of vue2 models now).
Yes, in the sense that LDflex wiring is completely configurable. So by rewiring this, you can have other behavior.
However, it would be difficult in the sense that:
data.things.foo.bar
andawait data.things.foo.bar
being different things. If they are not, then you would have to execute a query on every step, i.e.,data.things
,data.things.foo
,data.things.foo.bar
, even if you only need the last result.data.things.foo.bar.items
.Yeah, but so as mentioned above, there is thus still the JSON-LD parsing and the querying that is asynchronous, and the fact that
await
is also used as a trigger for “just query it now”.I see the appeal indeed. That would not be impossible to wire, but would take some implementation work.