This is a GraphQL-LD engine for executing queries using the Comunica query engine with Solid authentication.
This tool is identical to graphql-ld-comunica, with the additional feature that HTTP requests are authenticated using Comunica SPARQL Solid.
This requires you to install graphql-ld-comunica-solid: yarn add graphql-ld-comunica-solid
.
import {Client} from "graphql-ld";
import {QueryEngineComunicaSolid} from "graphql-ld-comunica-solid";
import {interactiveLogin} from "solid-node-interactive-auth";
// Define a JSON-LD context
const context = {
"@context": {
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"label": "rdfs:label",
"foaf": "http://xmlns.com/foaf/0.1/",
"name": "foaf:name",
"img": "foaf:img",
"interests": "foaf:topic_interest",
"RUBEN": { "@id": "https://www.rubensworks.net/#me" }
}
};
// Create a GraphQL-LD client based on a client-side Comunica engine over 2 sources
const comunicaConfig = {
sources: [
"https://www.rubensworks.net/",
"http://fragments.dbpedia.org/2016-04/en",
],
// This will open your Web browser to log in.
// Other mechanisms to obtain your session may also be used instead.
session: await interactiveLogin({ oidcIssuer: 'https://solidcommunity.net/' }),
};
const client = new Client({ context, queryEngine: new QueryEngineComunicaSolid(comunicaConfig) });
// Define a query
const query = `
query @single {
id(_:RUBEN)
name @single
img @single
interests {
id @single
label @single
}
}`;
// Execute the query
const { data } = await client.query({ query });
This software is written by Ruben Taelman.
This code is released under the MIT license.