comunica / actor-http-solid-auth-fetch

📬 A HTTP actor that makes use of the solid-auth-client library for its requests
0 stars 3 forks source link

QUESTION: How to use actor-http-solid-auth-fetch #29

Closed christianpe98 closed 4 years ago

christianpe98 commented 4 years ago

Hello! I am a university student and for one subject we are trying to develop an application following the Solid specifications. I have seen this Comunica module and I would like to use it as I find it really interesting. Because I'm new to the Comunica framework I don't have much idea how to use this module. Could someone teach me?

Right now I'm doing the queries in the following way:

...
import * as comunica from "@comunica/actor-init-sparql";
...
const engine=comunica.newEngine();
//sparql is a query and url is an endpoint
 const result= await engine.query(sparql,{sources:[url]});

Should I change the newEngine() to newDynamicEngine() and then somehow point out this actor? or is it done differently?

Thanks in advance!!!

rubensworks commented 4 years ago

Should I change the newEngine() to newDynamicEngine() and then somehow point out this actor? or is it done differently?

That would indeed be a good way to get started.

In this call, you should pass a custom config file in which you configure your custom Comunica engine with this Solid actor. You can start from the default config.

You can have a look at the LDflex config, which also uses this Solid fetch actor.

Let me know if you need any further pointers.

(FYI, I plan to make a tutorial on how you can create such custom Comunica configs somewhere in the next couple of weeks)

christianpe98 commented 4 years ago

Thank you, Ruben! I've been trying to use newEngineDynamic as is indicated in the comunica/actor-init-sparql README but I can't get it to work. newEngineDynamic is shown as undefined... I don't understand why this is happening. My code is as follows:

import {newEngineDynamic} from '@comunica/actor-init-sparql';
...
console.log(newEngineDynamic);
const engine=await newEngineDynamic({ configResourceUrl: 'src/config/config-solid.json' });

Do you know why it happens?

rubensworks commented 4 years ago

This seems to work fine for me. Are you sure you're using the latest version?

Are you by any chance testing this within a browser environment? Because newEngineDynamic is not included in browser builds.

christianpe98 commented 4 years ago

Oh yes im using it in a browser evironment. Thanks for your help!! I'll try other options

rubensworks commented 4 years ago

I've created a dedicated Comunica examples repo, which contains an example of what you want to do.

Feel free to open an issue there should things not be clear, or if you would encounter problems.