o-development / ldo

Monorepo for Linked Data Objects (ldo)
MIT License
23 stars 5 forks source link

getResource should support Leaf with a URI ending with '/' #40

Open pchampin opened 2 months ago

pchampin commented 2 months ago

Assume I need to load the QUDT ontology:

getResource("https://qudt.org/schema/qudt/").read().then(result => {
  console.log(result);
}

This displays an error "Error: Response from https://qudt.org/schema/qudt/ is not compliant with the Solid Specification: No link header present in request."

I can see why this is happening: LDO is assuming, from the URI, that the resource will be a container. So it checks for the link header with rel="typ" to ldp:Container, and complains about it not being there. That's a reasonable default, but there are cases where it should be overridable.

Indeed, not all RDF resources are complying with the Solid protocol (in particular, with Solid's Slash semantics), and they are still useful in a Solid application.

My suggestion is to add an optional parameterforceLeaf to getResource, which would force it to consider the resource as a Leaf, regardless of its URI.

I can try to make a PR for this if you think this is a good idea.

elf-pavlik commented 1 month ago

I only use @ldo/ldo and @ldo/solid, not the @ldo/solid-react. Since getResource is defined on LdoSolidDataset it makes sense that it follows the (very unfortunate :angry:) 'slash semantics'.

Do you need to have the resource that is not hosted in a solid storage in your LdoSolidDataset? Since there is no access control, using regular fetch and parseRdf might be enough.

pchampin commented 1 month ago

Since getResource is defined on LdoSolidDataset

That's something that I overlooked. In solid-react, you obtain getResource from a method named useLdo, so it looks like a simple LDO concept, not necessarily related to Solid...

it makes sense that it follows the (...) 'slash semantics'.

Fair enough.

the (very unfortunate 😠) 'slash semantics'

Let's not dive into that rabbit hole :wink:

Do you need to have the resource that is not hosted in a solid storage in your LdoSolidDataset?

Yes, because my Solid resources refer to things in the ontology, and my graph of shapes "span" across the boundaries between Solid and non-Solid resources.

Since there is no access control, using regular fetch and parseRdf might be enough.

I can do that. But then @ldo/solid should do that too :imp:. One instance of this issue happens with my WebID, which is https://champin.net/#pa, during login (and therefore out of my control).