LDflex / LDflex

A JavaScript DSL for querying Linked Data on the Web
https://ldflex.github.io/LDflex/
MIT License
176 stars 18 forks source link

Pagination #37

Open jblemee opened 5 years ago

jblemee commented 5 years ago

Hello,

I need LDFlex to support pagination and I would like some advice before starting an PR.

Do someone think about this feature in LDFLex. If yes, how do you see it ?

I was thinking of something like :

path = path.create({ subject: namedNode('https://ruben.verborgh.org/profile/#me') })
next_path = path.next() // return a new path following the " Link: url; rel='next' " header
previous_path = path.previous() // Follow the previous header
RubenVerborgh commented 5 years ago

The most crucial challenge is if and how pagination fits into LDflex conceptually. I see two issues:

  1. The relation is between documents. So it would not be data["https://ruben.verborgh.org/profile/#me"].next (given that #me is not the document) but data["https://ruben.verborgh.org/profile/"].next (given that /profile/ is a document and that the next link has that document as starting point)

  2. The Link header contents are not part of the document triples, whereas LDflex currently focuses on those.

I can elaborate on both, but already wanted to get the main points across.

jblemee commented 5 years ago
  1. Ok should it be more something like :
const queryEngine = new ComunicaEngine('https://ruben.verborgh.org/profile/');
const path = new PathFactory({ context, queryEngine });
const nextPathFactory = path.next()
const ruben = nextPathFactory.create({ subject: namedNode('https://ruben.verborgh.org/profile/#me') })

?

  1. Is there a way to access headers on LDFlex ? Since we have the base url on the queryEngine, we could do an 'OPTIONS' request on this url and get the headers.
RubenVerborgh commented 5 years ago
  1. Yes, that would be the way.

  2. It's not a technical limitation; the implementation could do a GET on the document and read+parse the Link header. The question is rather whether we should, because the idea of LDflex is to query the RDF data inside of the representation. So what if an actual next link is part of the representation? Do we treat it equally, or with priority? This is part of a bigger discussion on whether hypermedia controls should be part of the representation or the HTTP headers (and in the latter case, whether the "triples" in the HTTP Link and other headers can be considered triples).

So at the moment, I don't think such functionality is a good fit for LDflex.