I’m having some problems trying to develop the code to list the friends of one friend. I figured this would be possible as when you go to someone’s URL https://pod.solid.community/profile/card#me you can see all their friends. I manage to do the exact same thing on my application. Is there any source code that i can reuse or look at as inspiration? Or can someone explain to me how to do this?
I didn’t know about this tool. I was trying to do it using the rdf lib, developing in Typescript / Angular. Is there any way of doing it using the rdf lib? If not i will just install ldflex.
Just tried to install solid ldflex with npm install @solid/query-ldflex and it throws an error trying to access a repo called gwicke/web-streams-polyfill
I’m sure there is, but I’m not sure what it would be off the top of my head. LDFlex is a great tool for getting started in my opinion, as it simplifies a lot of the overhead of tools like rdflib.js. It still has the Subject-Predicate setup, it just makes it easier to read and write.
(side note: I looked up rdflib, as it’s been a while, and I think you’d need to set up a fetcher object, then load up the data like so: )
Then you have the friend webId and you can do the same thing with their webId, or query for some other predicate.
If you’re not too react-adverse, we do have a Solid React SDK that comes with some sample code and LDFlex integration already baked into it (for the quickest start, we have a yeoman generator for a Solid React sample app). It doesn’t have a friends example (yet) but it does get you started.
Here’s an example using solid-file-client. The fetchAndParse method returns an rdflib indexedGraph object so the code following it would work in straight rdflib as well:
async function main(){
let profile = "https://jeffz.solid.community/profile/card"
let store = await fc.fetchAndParse(profile)
let knows = store.sym("http://xmlns.com/foaf/0.1/knows")
let name = store.sym("http://xmlns.com/foaf/0.1/name")
let me = store.sym( profile + "#me" )
let friends = store.each( me, knows )
friends.forEach( friend => {
let friendsName = store.any( friend, name )
if(typeof friendsName !="undefined"){
console.log( freindsName.value )
}
})
}
That looks like a problem with github rather than the specific repo - are you behind a firewall or otherwise unable to install other packages? The error seems to indicate npm can’t connect to github.com
Trying to use this option, i include the solid-file-client in my project with npm install solid-file-client. I initialize it as const fileClient = require(‘solid-file-client’), having require previously declared as require: any as im using typescript. Anyhow, i get this error:
It is strange as im doing exactly the same as in one of my previous projects and this didnt happen. In the previous project i had the 0.4.9 and in this one it is the 0.5.1.
Oh darn, that null keeps causing me problems :-). I suggest you revert to 0.4.9 for the time being. I and my collaborators are working on 1.0.0 so I’m unlikely to fix 0.5.1, perhaps I’ll remove it. @bourgeoa, any thoughts?
v0.5.2 Done, build Ok tested with solid-ide OK, pushed to npm 0.5.2
Should solve the null module not found error encountered here and with react solid.
And another thing, trying your piece of code for listing friends, the last line (where i get the node values, store.any( friend, name ).value ) gives me an error i cannot understand. When I try to get the actual value of the node it prints out “Can’t get value of undefined”, but the list of friends is correct. It is actually defined as in the array you can find the correct info:
As for the undefined value - if store methods such as any() do not find anything, they returned undefined so it is actually bad practice to directly print the value as I did. Better to first check if any() returned something and then print the value. But, then we ask, why didn’t it get something. My guess is that you do not have a foaf:name field in your profile for the records for the people you know. It can only find fields that exist :-). If that turns out not to be the problem, come on back.