Registry / database / graphql-ld

graphql-ld

JSON →
library2.0.0jsnpmunverified

Query Linked Data using GraphQL queries and JSON-LD contexts. v2.0.0 converts GraphQL queries to SPARQL, executes them via local or remote engines, and returns tree-structured results. Bridges the gap between GraphQL developers and RDF/SPARQL ecosystems. Requires a separate query engine package (graphql-ld-comunica or graphql-ld-sparqlendpoint).

npm install graphql-ld
INSTALL
IMPORT
SIG · GRAPHQL-LD
G
graphql-ld
databasejavascriptv2.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Client
import { Client } from 'graphql-ld'
import Client from 'graphql-ld'
Default export is an object; use named import for Client class.
Client
const { Client } = require('graphql-ld')
const Client = require('graphql-ld')
CommonJS requires destructuring the named export.
QueryEngineComunica
import { QueryEngineComunica } from 'graphql-ld-comunica'
import { QueryEngineComunica } from 'graphql-ld'
This engine is in a separate package, not part of graphql-ld core.

Shows basic setup: create a Client with a JSON-LD context and a Comunica query engine, then execute a simple GraphQL query.

import { Client } from 'graphql-ld'; import { QueryEngineComunica } from 'graphql-ld-comunica'; const context = { "@context": { "label": { "@id": "http://www.w3.org/2000/01/rdf-schema#label" } } }; const client = new Client({ context, queryEngine: new QueryEngineComunica({ sources: ['http://dbpedia.org/sparql'] }) }); const query = `query @single { label }`; const { data } = await client.query({ query }); console.log(data);
Debug
Known issues
breakingThe Client constructor now requires the 'queryEngine' option; passing only context will fail in v2.0.0.
fix
Provide a queryEngine instance, e.g., new QueryEngineComunica({...}).
affects: >=2.0.0
deprecatedThe 'sparqlEndpoint' option in Client constructor has been deprecated since v2.0.0.
fix
Use the graphql-ld-sparqlendpoint package instead and pass its engine to 'queryEngine'.
affects: >=2.0.0
gotchaThe query object must use the @single directive as shown; omitting it may return unexpected nested arrays.
fix
Include @single in your GraphQL query if you expect a single result.
affects: >=1.0.0
breakingESM-only since v2.0.0; require() still works via Node.js CJS interop but is not guaranteed in all bundlers.
fix
Use import syntax in ES modules. If required CommonJS, use dynamic import() or ensure bundler compatibility.
affects: >=2.0.0
Errors
Common errors & fixes
Error: No query engine provided
Client constructor was called without a 'queryEngine' option (required since v2.0.0).
fix
new Client({ context, queryEngine: new QueryEngineComunica({...}) })
TypeError: Cannot read properties of undefined (reading 'sources')
QueryEngineComunica configuration object is missing or malformed.
fix
Ensure sources array is present: new QueryEngineComunica({ sources: [...] })
SyntaxError: Expected '}' but found 'label'
GraphQL query string is malformed; often missing quotation marks in context.
fix
Double-check the GraphQL query syntax and JSON-LD context JSON formatting.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
graphql-ld-comunicaoptionalRequired for client-side query execution against local or remote SPARQL endpoints
graphql-ld-sparqlendpointoptionalRequired for query execution via a remote SPARQL endpoint
Agent activity
8 hits · last 30 days
node
8
Resources
graphql-ld — npm install graphql-ld · libregistry