An open API service indexing awesome lists of open source software.

https://github.com/solidlabresearch/query-sparql-link-traversal-solid-no-default-predicates

A @comunica/query-sparql-link-traversal-solid, configured to not follow any default predicates.
https://github.com/solidlabresearch/query-sparql-link-traversal-solid-no-default-predicates

Last synced: 3 months ago
JSON representation

A @comunica/query-sparql-link-traversal-solid, configured to not follow any default predicates.

Awesome Lists containing this project

README

          

# query-sparql-link-traversal-solid-no-default-predicates

A [@comunica/query-sparql-link-traversal-solid](https://www.npmjs.com/package/@comunica/query-sparql-link-traversal-solid) engine,
configured to **not follow any default predicates** (such as `http://www.w3.org/2000/01/rdf-schema#seeAlso`).

It allows you

* to use an engine with this behavior, without the need to provide your own configuration file
* and even to apply it in a browser environment.

To use it, see below an example code snippet.

## Installation

In your application's project root folder, execute:

```bash
npm install query-sparql-link-traversal-solid-no-default-predicates
```

## Usage within application

This is an example demonstrating how to use this engine to retrieve datasources from an index file containing triples `?s ?source`.

```javascript
// This works in node AND in a browser (when packaged by vite for example).
import { QueryEngine } from 'query-sparql-link-traversal-solid-no-default-predicates';
const engine = new QueryEngine;

async function getSourceList() {
const bindingsStream = await engine.queryBindings(
'SELECT DISTINCT ?source WHERE {?s ?source.}',
{
sources: ['http://example.com/index-file-with-triples-listing-sources'],
lenient: true
});
let sources = [];
const bindings = await bindingsStream.toArray();
for (let binding of bindings) {
sources.push(binding.get('source').value)
}
return sources;
}

const datasources = await getSourceList();
console.log(datasources);
```

### Note

Replacing the top 3 lines in above example with:

```javascript
// This only works in node (suppose ./config.json has the same contents as query-sparql-link-traversal-solid-no-default-predicates's engine-default.js).
import { QueryEngineFactory } from '@comunica/query-sparql-link-traversal-solid';
const engine = await new QueryEngineFactory().create({ configPath: './config.json', });
```

would not work in a browser environment, because `QueryEngineFactory` is not available there.