1.2.2 • Published 2 years ago

graphql-ld-comunica v1.2.2

Weekly downloads
4
License
MIT
Repository
github
Last release
2 years ago

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.