Skip to content

Instantly share code, notes, and snippets.

View rubensworks's full-sized avatar

Ruben Taelman rubensworks

View GitHub Profile

This document describes the steps to use a prerelease of Comunica 2.x.

Intended release date: Somewhere in the week of Monday 28 February


  • This is major update with breaking changes, which means that old invocations of Comunica will have to be changed slightly.
  • The READMEs and documentation on have not been updated yet, so you will have to discover the usage of the new API via autocompletion of an IDE with TypeScript support.
  • The Comunica prereleases depend on the new RDF/JS typings (@rdfjs/types@1.1.0).

Getting started:

interface Queryable<SourceType> {
query(query: string, context?: QueryStringContext<SourceType>): Promise<QueryResult>
interface QueryableAlgebra<SourceType> {
query(query: Algebra, context?: QueryAlgebraContext<SourceType>): Promise<QueryResult>
// TODO: what about update queries?

We require three new handles:

  • InsertHandler: binds to add.
  • DeleteHandler: binds to delete.
  • UpdateHandler (optional): binds to set and replace.

Getting random values

await user.friends.friends.random // returns a random friend
Small equal:
> Triples: 276
isomorphic: 24.378ms
canonize: 5.570ms
Small non-equal:
> Triples: 276
isomorphic: 1.216ms
canonize: 4.184ms


GraphQL-LD is a way to query Linked Data using GraphQL.

Instead of querying GraphQL interfaces, Linked Data interfaces are queried, such as SPARQL endpoints, TPF interfaces, Linked Data documents, ... This is done by semantifying GraphQL queries using a JSON-LD context.

Try it out from your browser:

Alternatively, install GraphQL-LD or Comunica SPARQL and execute GraphQL-LD queries on your machine

:myFriends {
  ex:Alice foaf:knows ex:Bob.
  ex:Alice foaf:knows ex:Carol.

Remove a single quad

I guess this is supported?

This is a short guide that explains how you can execute a federated query with Comunica.

Command line

We will execute a query to find all books in the Harvard Library that were written by people who were born in Ghent. We do this by federating over DBpedia (SPARQL), the Harvard library (TPF) and the VIAF dataset (TPF).

  1. Make sure Node.js (>=8.0.0) is installed:
  2. Install Comunica: npm install -g @comunica/actor-init-sparql
  3. Execute the following command: