# Help using different libs: rdflibjs, tripledoc, ldflex, solid-file-client

**URL:** <https://forum.solidproject.org/t/help-using-different-libs-rdflibjs-tripledoc-ldflex-solid-file-client/2388>\
**Category:** General Discussion\
**Created:** [November 13, 2019, 11:10pm UTC](https://forum.solidproject.org/t/help-using-different-libs-rdflibjs-tripledoc-ldflex-solid-file-client/2388 "2019-11-13T23:10:45Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Smag0](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/smag0/32/310_2.png) [@Smag0](https://forum.solidproject.org/u/Smag0)\
**Post date:** [November 13, 2019, 11:10pm UTC](https://forum.solidproject.org/t/help-using-different-libs-rdflibjs-tripledoc-ldflex-solid-file-client/2388/1 "2019-11-13T23:10:45Z")

</div>

I want to make a widget like @Vincent 's [Notepod](http://forum.solidproject.org/t/notepod-a-note-taking-app-for-solid/2371) for [Solidash](https://scenaristeur.github.io/solidash/)

Some constraints :

- I want my app that could be easily changeable and really simple, so I don’t want any webpack or build.
- for the simplicity of hosting on github-pages or on a Pod, I don’t want any techno server as node/express, and use prepackages libs for accessing and managing data on a Pod.  
( I put node but only to download modules, but I don’t want to use it in prod)
- I don’t like Angular or React, perhaps because I’ve discovered Polymer first, and I like the concept of web-components Polymer provides.

So for every libs in the list and why not other, it would be nice if someone that know how to read data, create data, update data, to do the same actions as Notepod.  
It could be a good example of how to do this type of action, and could help us to compare.  
That could also be a complement to @Vincent cheatsheet.

- rdflibjs
- @jeffz solid-file-client
- @Vincent tripledoc
- ldflex  
\*…

Example of integration in app can be found here [https://github.com/scenaristeur/solidash/blob/2a7bc7e18f7772b142df79aec14c1e397b98d482/components/app-element.js#L18](https://github.com/scenaristeur/solidash/blob/2a7bc7e18f7772b142df79aec14c1e397b98d482/components/app-element.js#L18)

and components are instance of LitElemet class like this one [https://github.com/scenaristeur/solidash/blob/master/components/fileclient-notepod.js](https://github.com/scenaristeur/solidash/blob/master/components/fileclient-notepod.js)

- I’ve tried with solid-file-client but I don’t know how to update, or add a line in a turtle file, and it seams that it loads more than one version of solid-auth !? @jeffz?
- I’ve tried with tripledoc, but I was not able to load a browser version of tripledoc & rdf-namespaces

**So I would like to build some examples of each lib as simple as possible to add some notes on a Pod. Could everyone expert on those libs help me ?**

Thxs

- @dprat0821 😜  
I’ve used evejs (Multi-agents js lib for communication between each component) but this must not interfere with rdf libs, because it’s another part of the project

---

<div class="post-metadata">

**Author:** ![aveltens](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/aveltens/32/3987_2.png) [@aveltens](https://forum.solidproject.org/u/aveltens)\
**Post date:** [November 14, 2019, 8:05am UTC](https://forum.solidproject.org/t/help-using-different-libs-rdflibjs-tripledoc-ldflex-solid-file-client/2388/2 "2019-11-14T08:05:10Z")

</div>

This repo has some examples that might be helpful:

> **[inrupt/solid-lib-comparison](https://github.com/inrupt/solid-lib-comparison)**
>
> Three branches with common Solid operations implemented in rdflib, ldflex and Tripledoc, respectively

---

<div class="post-metadata">

**Author:** ![Vincent](https://avatars.discourse-cdn.com/v4/letter/v/e9bcb4/32.png) [@Vincent](https://forum.solidproject.org/u/Vincent)\
**Post date:** [November 14, 2019, 9:33am UTC](https://forum.solidproject.org/t/help-using-different-libs-rdflibjs-tripledoc-ldflex-solid-file-client/2388/3 "2019-11-14T09:33:54Z")

</div>

For reference, [here’s the cheatsheet mentioned](https://vincenttunru.gitlab.io/tripledoc/docs/cheatsheet).

I would certainly recommend a bundler, because it will remove code for you that is unused. However, I just published v2.4 of Tripledoc that also includes a browser bundle. ~~Do note that you will also currently need to include rdflib in your page, which is used by Tripledoc. [Here’s an example of how to run Tripledoc without a bundler.](https://codesandbox.io/s/xenodochial-wood-fu9cp)~~ Update: Tripledoc v3 and above no longer use rdflib behind the scenes, but N3.js. [Here’s an updated example of running Tripledoc without manually running a bundler.](https://codesandbox.io/s/hardcore-elion-11ko6)

The examples in the Cheatsheet for rdflib should work as well by just including a `<script>` tag pointing to rdflib, but you’ll need to change code like

```javascript
import { graph } from "rdflib";

const store = graph();

```

to

```javascript
const store = $rdf.graph();

```

Does that help?

---

<div class="post-metadata">

**Author:** ![Smag0](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/smag0/32/310_2.png) [@Smag0](https://forum.solidproject.org/u/Smag0)\
**Post date:** [November 14, 2019, 10:51am UTC](https://forum.solidproject.org/t/help-using-different-libs-rdflibjs-tripledoc-ldflex-solid-file-client/2388/4 "2019-11-14T10:51:34Z")

</div>

@Vincent thxs , i will try it [https://github.com/scenaristeur/solidash/blob/f21ae8f045d08507ee089e36976ae8d3b48edf8c/components/my-tripledoc.js#L48](https://github.com/scenaristeur/solidash/blob/f21ae8f045d08507ee089e36976ae8d3b48edf8c/components/my-tripledoc.js#L48)

---

<div class="post-metadata">

**Author:** ![dprat0821](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/dprat0821/32/203_2.png) [@dprat0821](https://forum.solidproject.org/u/dprat0821)\
**Post date:** [November 14, 2019, 9:22pm UTC](https://forum.solidproject.org/t/help-using-different-libs-rdflibjs-tripledoc-ldflex-solid-file-client/2388/5 "2019-11-14T21:22:07Z")

</div>

Thanks for sharing. Just checked that evejs does a good job in providing the multi-agent communication layer.

Just FYI, [Rxjs](https://rxjs-dev.firebaseapp.com/) can simplify your logic in handling some practical complexities (such as throttle to filter duplicated messages, etc.)

For the agent communication, the [actor model](https://en.wikipedia.org/wiki/Actor_model) (eg. [Akka](https://akka.io/) ) were once very popular, now [ReactiveX](http://reactivex.io/) (eg. Rxjs mentioned above) is trending as well. You can find implementations for different languages (Java, Js, C#, …) in case you need to support different platforms with same framework.

---

<div class="post-metadata">

**Author:** ![Smag0](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/smag0/32/310_2.png) [@Smag0](https://forum.solidproject.org/u/Smag0)\
**Post date:** [November 15, 2019, 9:38am UTC](https://forum.solidproject.org/t/help-using-different-libs-rdflibjs-tripledoc-ldflex-solid-file-client/2388/6 "2019-11-15T09:38:01Z")

</div>

@Vincent  
Cool, it folks on [https://scenaristeur.github.io/solidash/](https://scenaristeur.github.io/solidash/) !  
but on this page [https://solidproject.org/for-developers/apps/first-app/4-data-model](https://solidproject.org/for-developers/apps/first-app/4-data-model)

```auto
  typeRegistration.addRef(solid.instance, document.asRef())

```

shouldn’t be

```auto
  typeRegistration.addRef(solid.instance, **notesList**.asRef())

```

-\> How do you open the page that propose to the user to add your app to “Trusted Apps”?  
Thxs

---

<div class="post-metadata">

**Author:** ![Vincent](https://avatars.discourse-cdn.com/v4/letter/v/e9bcb4/32.png) [@Vincent](https://forum.solidproject.org/u/Vincent)\
**Post date:** [November 15, 2019, 1:17pm UTC](https://forum.solidproject.org/t/help-using-different-libs-rdflibjs-tripledoc-ldflex-solid-file-client/2388/7 "2019-11-15T13:17:39Z")

</div>

Thanks for spotting that, that should indeed be `notesList.asRef()`. That was actually fixed in a draft version, but for some reason didn’t make it onto the live site - we’ll have that fixd soon.

As for your other question, you’re talking about this page right?

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/solidproject/original/2X/f/f6ee265be2042a3d680153ca97fe98740d0ba3b3.png)

Users get that the first time they connect their Pod to an app on your origin (i.e. [scenaristeur.github.io](http://scenaristeur.github.io)) when that origin has not yet been added to their trusted apps, so if you follow [the authentication guide](https://solidproject.org/for-developers/apps/first-app/1-authentication), you should be set.

---

<div class="post-metadata">

**Author:** ![Smag0](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/smag0/32/310_2.png) [@Smag0](https://forum.solidproject.org/u/Smag0)\
**Post date:** [November 15, 2019, 3:00pm UTC](https://forum.solidproject.org/t/help-using-different-libs-rdflibjs-tripledoc-ldflex-solid-file-client/2388/8 "2019-11-15T15:00:10Z")

</div>

yes , this one, i’ll try, thxs

---

<div class="post-metadata">

**Author:** ![Smag0](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/smag0/32/310_2.png) [@Smag0](https://forum.solidproject.org/u/Smag0)\
**Post date:** [November 15, 2019, 9:56pm UTC](https://forum.solidproject.org/t/help-using-different-libs-rdflibjs-tripledoc-ldflex-solid-file-client/2388/9 "2019-11-15T21:56:47Z")

</div>

using this code

```auto
async function popupLogin() {
let session = await solid.auth.currentSession();
let popupUri = 'https://solid.community/common/popup.html';
if (!session)
session = await solid.auth.popupLogin({ popupUri });
}

```

in this module [https://github.com/scenaristeur/solidash/blob/master/js/modules/solid-auth.js](https://github.com/scenaristeur/solidash/blob/master/js/modules/solid-auth.js) does not give me the page for “Trusted Apps” when I click on “login button”.

I use a copy of solid-auth-client.bundle.js found in “node\_modules/solid-auth-client/dist-lib”  
Do you have a idea why I don’t have the “trusted app” window ?

---

<div class="post-metadata">

**Author:** ![Vincent](https://avatars.discourse-cdn.com/v4/letter/v/e9bcb4/32.png) [@Vincent](https://forum.solidproject.org/u/Vincent)\
**Post date:** [November 16, 2019, 1:34pm UTC](https://forum.solidproject.org/t/help-using-different-libs-rdflibjs-tripledoc-ldflex-solid-file-client/2388/10 "2019-11-16T13:34:02Z")

</div>

That’s because your `popupUri` refers to `solid.community`, so users are actually logging in to there. Presumably, `solid.community` is already in your trusted apps list, which is why you’re not seeing the login. This is what I get:

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/solidproject/original/2X/4/4d08195dd38ae9257ee498208ae1ef3fc38b15a2.png)

Note that it asks me to authorise `solid.community` rather than `scenaristeur.github.io`.

To fix it, you can either:

- Host the `popup.html` yourself - it can be downloaded from [here](https://solid.github.io/solid-auth-client/dist/popup.html).
- Provide our own UI that allows people to enter their identity provider (e.g. `https://inrupt.net` or `https://solid.community`), instead of using `popupLogin`. [Here’s an example.](https://codesandbox.io/s/romantic-wood-0i6z7?module=%2Fsrc%2Findex.js)

---

<div class="post-metadata">

**Author:** ![Smag0](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/smag0/32/310_2.png) [@Smag0](https://forum.solidproject.org/u/Smag0)\
**Post date:** [November 17, 2019, 3:52pm UTC](https://forum.solidproject.org/t/help-using-different-libs-rdflibjs-tripledoc-ldflex-solid-file-client/2388/11 "2019-11-17T15:52:44Z")

</div>

@Vincent  
ok, i use a local popup ( let popupUri = ‘./dist-popup/popup.html’😉  
and it looks good.  
thxs

---

<div class="post-metadata">

**Author:** ![Smag0](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/smag0/32/310_2.png) [@Smag0](https://forum.solidproject.org/u/Smag0)\
**Post date:** [March 24, 2020, 3:31pm UTC](https://forum.solidproject.org/t/help-using-different-libs-rdflibjs-tripledoc-ldflex-solid-file-client/2388/12 "2020-03-24T15:31:22Z")

</div>

Hi Soliders are there big performance differences between the different libs

- @Vincent Tripledoc [https://vincenttunru.gitlab.io/tripledoc/docs/getting-started.html](https://vincenttunru.gitlab.io/tripledoc/docs/getting-started.html)
- @RubenVerborgh query-ldflex [https://github.com/solid/query-ldflex](https://github.com/solid/query-ldflex) & rdflib [https://github.com/solid/solid-tutorial-rdflib.js](https://github.com/solid/solid-tutorial-rdflib.js)
- @jeffz solid-file-client [https://github.com/jeff-zucker/solid-file-client](https://github.com/jeff-zucker/solid-file-client)
- @NoelDeMartin Souka [Soukai: A different way to query PODs](http://forum.solidproject.org/t/soukai-a-different-way-to-query-pods/2105)
- communica [https://github.com/comunica](https://github.com/comunica)
- graphy.js [Best JS libraries to help build visualisation components of RDF (using Sveltejs)](http://forum.solidproject.org/t/best-js-libraries-to-help-build-visualisation-components-of-rdf-using-sveltejs/2548?u=happybeing)

I’m asking that because I must impove performance of [Shighl](https://github.com/scenaristeur/shighl) for [Solidarity’s Chat](https://github.com/scenaristeur/solidarity).  
For now Shighl is based on query-ldflex, but i think there is a lot of await to parse all chat messages and @jucole confirm some degradation So does anyone have an idea of which is the most performant for this task before i start to rewrite ?  
Or do I have to low deal with Sparql query ?  
Thxs

---

<div class="post-metadata">

**Author:** ![jeffz](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/jeffz/32/600_2.png) [@jeffz](https://forum.solidproject.org/u/jeffz)\
**Post date:** [March 24, 2020, 4:01pm UTC](https://forum.solidproject.org/t/help-using-different-libs-rdflibjs-tripledoc-ldflex-solid-file-client/2388/13 "2020-03-24T16:01:13Z")

</div>

As far as I know, all of those libraries use solid-auth-client.fetch() to do actual Input/Output. It would be interesting to see if they have much of a difference in speed, I wouldn’t expect it. Solid-File-Client is good at managing files and folders. If you need to copy a bunch of things or you need to create a certain file/folder structure on the user’s pod - it’s a good choice. It does not do any of the parsing, So if you need to do triple-level patching or reasoning or anything other than managing the files, you should use one of the other libraries for that. [Edit : well it does some parsing - it returns the structure and contents of folders and the types and other metadata of files and folders and parses link headers so that it knows how to handle .acl and other linked resources]

---

<div class="post-metadata">

**Author:** ![Smag0](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/smag0/32/310_2.png) [@Smag0](https://forum.solidproject.org/u/Smag0)\
**Post date:** [March 24, 2020, 6:20pm UTC](https://forum.solidproject.org/t/help-using-different-libs-rdflibjs-tripledoc-ldflex-solid-file-client/2388/15 "2020-03-24T18:20:14Z")

</div>

Thxs for that infos, is there a simple way to switch to rdflib instead of communica in ldflex-query?  
Edit : forget Ok I see it [https://github.com/solid/query-ldflex/blob/master/README.md](https://github.com/solid/query-ldflex/blob/master/README.md)

---

<div class="post-metadata">

**Author:** ![NoelDeMartin](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/noeldemartin/32/3144_2.png) [@NoelDeMartin](https://forum.solidproject.org/u/NoelDeMartin)\
**Post date:** [March 24, 2020, 6:48pm UTC](https://forum.solidproject.org/t/help-using-different-libs-rdflibjs-tripledoc-ldflex-solid-file-client/2388/16 "2020-03-24T18:48:47Z")

</div>

In the case of Soukai, something to keep in mind is that it implements the [Active Record](https://en.wikipedia.org/wiki/Active_record_pattern) pattern. This is important because one of the main critiques to this pattern is performance issues. The problem is not the pattern itself, but the fact that because it’s so “easy” to interact with a database (in this case, the network) it hides away how queries (in this case requests) are being performed. Perhaps the most relevant example is the [N+1 problem](https://stackoverflow.com/questions/97197/what-is-the-n1-selects-problem-in-orm-object-relational-mapping).

In my opinion this is not an issue and I use the pattern in most of my applications (not only Solid). But of course, you need to be careful with that. The important thing for performance issues is to inspect what queries are being performed under the hood (in this case network requests, which is easy to debug given browser dev tools 😃). If there is something too problematic, you can always fall back to other low-level solutions like using `solid-auth-client` yourself.

That is, assuming your bottleneck is the network (which it usually is). If your performance issues lie in the JS layer and not the network, you need to be careful with how many instances you are creating and what you are doing with them. But I really doubt that’s the problem.

Other than that, there is an [open issue](https://github.com/solid/node-solid-server/issues/962) in `node-solid-server` and as far as I know, SPARQL queries are not supported. That’s why Soukai uses globbing under the hood and that can create problems depending how you have structured your data. I am having some performance issues in one application, but I don’t think it can be solved with any library since the problem lies in the server & data structure. In the end, I think my solution will be more related with having data cached in the browser rather than improving network requests, but I have to look into it.

---

<div class="post-metadata">

**Author:** ![Vincent](https://avatars.discourse-cdn.com/v4/letter/v/e9bcb4/32.png) [@Vincent](https://forum.solidproject.org/u/Vincent)\
**Post date:** [March 25, 2020, 9:31am UTC](https://forum.solidproject.org/t/help-using-different-libs-rdflibjs-tripledoc-ldflex-solid-file-client/2388/17 "2020-03-25T09:31:03Z")

</div>

There are no benchmarks I’m aware of, unfortunately, so I could only give you some high-level theorising about how different approaches might result in different performance characteristics, but since that would most likely be wrong (with limited knowledge of the different approaches and no benchmarks), I won’t try that.

In any case, LDflex uses Comunica behind the scenes, so that’s a switch that would not make sense. As Noel said, SPARQL is not supported, so you can scratch that approach as well. And Solid File Client is indeed focused more on complete files rather than parsing and manipulating RDF data, so that doesn’t really seem to make sense for this use case either.

Thus, the list could be shortened to Soukai, rdflib and Tripledoc - and potentially, manually sending requests with solid-auth-client. However, before trying it with a different library, take a look at the Network tab in your browser to rule out some potential other causes. Are you seeing many HTTP requests to your Pod that could theoretically be a single one, indicating that you could rewrite your code? Are you seeing requests that take a long time to return a response, indicating that the problem is in the server response time?

---

<div class="post-metadata">

**Author:** ![happybeing](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/happybeing/32/59_2.png) [@happybeing](https://forum.solidproject.org/u/happybeing)\
**Post date:** [March 25, 2020, 10:20am UTC](https://forum.solidproject.org/t/help-using-different-libs-rdflibjs-tripledoc-ldflex-solid-file-client/2388/18 "2020-03-25T10:20:40Z")

</div>

Don’t forget graphy.js which is performant wrt RDF processing and I’ve been using. More on this and other libs here:

> [@Best JS libraries to help build visualisation components of RDF (using Sveltejs)](http://forum.solidproject.org/t/best-js-libraries-to-help-build-visualisation-components-of-rdf-using-sveltejs/2548):
>
> 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](https://github.com/blake-regalia/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 …

---

<div class="post-metadata">

**Author:** ![Smag0](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/smag0/32/310_2.png) [@Smag0](https://forum.solidproject.org/u/Smag0)\
**Post date:** [March 25, 2020, 4:28pm UTC](https://forum.solidproject.org/t/help-using-different-libs-rdflibjs-tripledoc-ldflex-solid-file-client/2388/19 "2020-03-25T16:28:07Z")

</div>

@RubenVerborgh  
Sorry but i don’t know how to migrate to rdflib instead of communica  
in my code here [https://github.com/scenaristeur/shighl/blob/master/src/Shighl-pod.js](https://github.com/scenaristeur/shighl/blob/master/src/Shighl-pod.js) i use

```auto
import data from "@solid/query-ldflex";

```

trying to replace by `'@solid/query-ldflex/lib/exports/rdflib'`  
doesn not work because there is no ‘exports’ folder in lib… Any idea ?  
Thxs

---

<div class="post-metadata">

**Author:** ![Smag0](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/smag0/32/310_2.png) [@Smag0](https://forum.solidproject.org/u/Smag0)\
**Post date:** [March 26, 2020, 6:58am UTC](https://forum.solidproject.org/t/help-using-different-libs-rdflibjs-tripledoc-ldflex-solid-file-client/2388/21 "2020-03-26T06:58:19Z")

</div>

Not sure , my package.json say “^2.9.0” [https://github.com/scenaristeur/shighl/blob/a2836ecc16f60d2177cf2a7f70067fa38f95b3fb/package.json#L48](https://github.com/scenaristeur/shighl/blob/a2836ecc16f60d2177cf2a7f70067fa38f95b3fb/package.json#L48)  
I’ll first upgrade😊

---

<div class="post-metadata">

**Author:** ![A\_A](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/a_a/32/786_2.png) [@A\_A](https://forum.solidproject.org/u/A_A)\
**Post date:** [March 26, 2020, 9:40am UTC](https://forum.solidproject.org/t/help-using-different-libs-rdflibjs-tripledoc-ldflex-solid-file-client/2388/22 "2020-03-26T09:40:32Z")

</div>

You can take a look at [your package-lock.json](https://github.com/scenaristeur/shighl/blob/master/package-lock.json#L3219-L3220) to see what version you currently use (2.9.0 in your case). May be helpful in the future :))

[Next page](https://forum.solidproject.org/t/help-using-different-libs-rdflibjs-tripledoc-ldflex-solid-file-client/2388.md?page=2)
