Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
🚀Power-coding

Ruben Taelman rubensworks

💭
🚀Power-coding
View GitHub Profile
View GraphQL-LD-Demo.md

GraphQL-LD

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: http://query.linkeddatafragments.org/

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

View comunica-federated.md

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: https://nodejs.org/en/
  2. Install Comunica: npm install -g @comunica/actor-init-sparql
  3. Execute the following command:
View comunica-2-pre-testing.md

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

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

Warnings:

  • 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 comunica.dev 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:

View rdfjs-query-interfaces.ts
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?
View perf-microdata-rdf-streaming-parser.md
View perf-rdfa-streaming-parser.md
View LDflex-write-support.md

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
View perf-rdfxml-streaming-parser.md
View rdf-isomorphic and rdf-canonize
Small equal:
> Triples: 276
isomorphic: 24.378ms
canonize: 5.570ms
Small non-equal:
> Triples: 276
isomorphic: 1.216ms
canonize: 4.184ms
View rdfstar-questions.md
:myFriends {
  ex:Alice foaf:knows ex:Bob.
  ex:Alice foaf:knows ex:Carol.
}

Remove a single quad

I guess this is supported?