A GraphQL-LD engine that is backed by a SPARQL endpoint
npm install graphql-ld-sparqlendpoint


This is a GraphQL-LD engine for executing queries against a remote _SPARQL endpoint_.
``javascript
import {Client} from "graphql-ld";
import {QueryEngineSparqlEndpoint} from "graphql-ld-sparqlendpoint";
// 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 SPARQL endpoint
const endpoint = 'http://dbpedia.org/sparql';
const client = new Client({ context, queryEngine: new QueryEngineSparqlEndpoint(endpoint) });
// Define a query
const query =
query @single {
label
};
// Execute the query
const { data } = await client.query({ query });
`
If you install this package globally (yarn global add graphql-ld-sparqlendpoint),graphql-ld-sparqlendpoint
then you'll have access to the script to execute GraphQL-LD queries from the command-line as follows:
Query based on context and query strings:
``
$ graphql-ld-sparqlendpoint '{ "hero": "http://example.org/hero", "name": "http://example.org/name" }' '{ hero { name } }' http://dbpedia.org/sparql
Query based on context and query files:
```
$ graphql-ld-sparqlendpoint context.json query.txt http://dbpedia.org/sparql
This code is released under the MIT license.