Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get method always returns null #258

Open
johnslaughter-ihsmarkit opened this issue Sep 28, 2021 · 3 comments
Open

get method always returns null #258

johnslaughter-ihsmarkit opened this issue Sep 28, 2021 · 3 comments

Comments

@johnslaughter-ihsmarkit
Copy link

johnslaughter-ihsmarkit commented Sep 28, 2021

I'm using the current published version of alcaeus (1.3.1). So far I have been unable to fetch property information using the get method. The typed helper method all seem to work however. I believe that the issue might stem from the rdfine lib - but I haven't had a chance to check that out yet.

EDIT:
On second look, I believe that the issue stems from the implementation of getArray in rdfine which filters out all properties that are not named or blank nodes.

https://github.com/tpluscode/rdfine/blob/377c603b222c30f75e8ecfe1ae6cd7dbfce5ccaf/packages/core/RdfResource.ts#L240

@tpluscode
Copy link
Member

Uh, yea, essentially the same problem that was #248. Sorry about that

To be honest I'm less sure how I'd want to tackle this. The general idea behind rdfine is to build strong-typed interfaces proxying RDF properties.

So instead of resource.get('http://example.com/myProperty') you would type resource.myProperty

Have you seen this on the docs page: https://alcaeus.hydra.how/latest/#/representations/mixins ?

@johnslaughter-ihsmarkit
Copy link
Author

That is helpful, thanks! Yes - I've seen the entry on mixins.
For some background, I'm building a generic semantic api explorer to increase my own knowledge. For now, I'll be using the property indexer on the resource (I still want to refer to the properties by their vocab)

@tpluscode
Copy link
Member

tpluscode commented Oct 14, 2021

If you intend to access the graph in the most generic way then maybe you don't really need the object model that much? rdfine, which sits inside alcaeus works best for closed-world models. The representation of the hydra vocab for example is generated and packaged as @rdfine/hydra.

For API- and case-specific model you may be working against the grain here. Instead, I could advise an approach where you describe your graphs in SHACL for example and base your code on the properties.

A core design of rdfine is that the RDF/JS representation is easily accessible so that you can consume the graph using other tools and not only the OOP models. See below and example where I reworked the example from the docs to use SHACL paths for accessing data inside resource returned from the example API

https://runkit.com/embed/g8u373kz6n72

Of course, the returned values are plain RDF/JS objects

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants