graphql-ld-comunica
TypeScript icon, indicating that this package has built-in type declarations

1.2.2 • Public • Published

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.

Package Sidebar

Install

npm i graphql-ld-comunica

Weekly Downloads

9

Version

1.2.2

License

MIT

Unpacked Size

9.58 kB

Total Files

9

Last publish

Collaborators

  • rubensworks