At last I’m playing with RDF and building Svelte components to visualise it! But what libs to use? Much of this will help choosing JS libs for any use case, but I’ll explain with my use case in mind.
UPDATE: for now I’ve settled on graphy.js for the following reasons:
- seems capable at a usefully low level (for me) and well designed for the real world (supports streams and set opertations for example, with SPARQL like filters in development)
- good balance between features and library size (at 360K overhead for my needs it’s bigger than Rdfjs/fetch but still much smaller than more capable alternatives:
rdflib.js
606K,LDFlex
+Comunica
adds 1.4M) - well documented and supported, and being developed extended
- complies with RDF/JS standards
Having failed to get rdflib working inside a Svelte component (see issue #381, but this is not the only blocker) I’m looking at other libs for fetching RDF resources and parsing them for visualisation, so easy iteration and query of a triple store is important. Later I might want to write RDF back.
There are several candidates that on scanning the repos look good. Any recommendations? I’d like advice for which will be easiest to iterate over returned triples in order to generate data for visualisation components.
The ones I’ve found are:
- GitHub - rubensworks/rdf-dereference.js: Dereference any URL for its RDF contents (and related rdf-parse.js)
- GitHub - blake-regalia/graphy.js: A collection of RDF libraries for JavaScript
- GitHub - rdfjs-base/fetch: Wrapper for fetch to simplify sending and receiving RDF data
- GitHub - ontola/rdfdev-js: Utilities for working with RDF/Linked Data in JavaScript / TypeScript
- GitHub - antoniogarrote/rdfstore-js: JS RDF store with SPARQL support
- rdf-ext · GitHub - I have a note of an old comment from Tim on this suggesting it is a bit low level (lacking ‘each’ etc.)
EDIT: There’s a handy Comparison of RDFJS libraries from the w3c, of some of these and some not mentioned.
The above was posted earlier on the Solid chat here, which added the following for consideration:
- GitHub - LDflex/LDflex: A JavaScript DSL for querying Linked Data on the Web
- VincentTunru / tripledoc · GitLab
I missed both of those because I had them filed under Solid/rdflib’ rather than as generic RDF libs. But now I see there is a generic and Solid specific version of LDFlex. Tripledoc depends on solid-auth-client, might be suitable, I’m not sure but I’ll probably steer clear of it to keep things ‘svelte’ and stay generic as possible, at least for now.
Following responses on the Solid chat and seeing that rdfjs uses w3c specified types I’m liking that and also the stream support of graphy.js so I’ll start with those, but would still like to hear of any alternatives and opinions on all these options from anyone.
Thanks.
Note: related to an earlier discussion of visualisation libraries, which lead me to focus on D3 for now (Visualisation libraries in JavaScript).
UPDATE
Here are some example Svelte components, one using each of Comunica/LDFlex, rdflib.js, Rdfjs and graphy. Very simple, but may help you get started: