Skip to content

Latest commit

 

History

History
45 lines (33 loc) · 1.8 KB

README.md

File metadata and controls

45 lines (33 loc) · 1.8 KB

Comunica for GraphQL-LD

Build status Coverage Status npm version

This is a GraphQL-LD engine for executing queries using the Comunica query engine.

If you want to use this for Solid apps, have a look at graphql-ld-comunica-solid instead.

Usage

This requires you to install graphql-ld-comunica: yarn add graphql-ld-comunica.

import {Client} from "graphql-ld";
import {QueryEngineComunica} from "graphql-ld-comunica";

// Define a JSON-LD context
const context = {
  "@context": {
    "label": { "@id": "http://www.w3.org/2000/01/rdf-schema#label" }
  }
};

// Create a GraphQL-LD client based on a client-side Comunica engine over 2 sources
const comunicaConfig = {
  sources: [ "http://dbpedia.org/sparql", "https://ruben.verborgh.org/profile/" ],
};
const client = new Client({ context, queryEngine: new QueryEngineComunica(comunicaConfig) });

// Define a query
const query = `
  query @single {
    label
  }`;

// Execute the query
const { data } = await client.query({ query });

License

This software is written by Ruben Taelman.

This code is released under the MIT license.