Registry / database / graphql-to-sparql

graphql-to-sparql

JSON →
library6.0.0jsnpmunverified

Converts GraphQL queries into SPARQL queries or SPARQL algebra using a JSON-LD context, enabling GraphQL-LD. Version 6.0.0 is released with TypeScript types. Supports nested fields, arguments, aliases, and reverse properties. Unlike generic RDF libraries, it provides a direct GraphQL-to-SPARQL conversion without intermediate representations.

npm install graphql-to-sparql
INSTALL
IMPORT
SIG · GRAPHQL-TO-SPARQL
G
graphql-to-sparql
databasejavascriptv6.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.

Converter
import { Converter } from 'graphql-to-sparql'
const { Converter } = require('graphql-to-sparql')
ESM-only since v6; CommonJS require is not supported.
graphqlToSparqlAlgebra
import { Converter } from 'graphql-to-sparql'; const algebra = await new Converter().graphqlToSparqlAlgebra(query, context)
import { graphqlToSparqlAlgebra } from 'graphql-to-sparql'
The function is not exported directly; you must instantiate Converter.

Converts a GraphQL query to SPARQL algebra using a JSON-LD context with nested fields.

import { Converter } from 'graphql-to-sparql'; const context = { hero: 'http://example.org/hero', name: 'http://example.org/name', friends: 'http://example.org/friends' }; const converter = new Converter(); const algebra = await converter.graphqlToSparqlAlgebra('{ hero { name friends { name } } }', context); console.log(JSON.stringify(algebra, null, 2));
Debug
Known issues
breakingESM-only since v6.0.0: CommonJS require() will throw an error.
fix
Use import syntax instead of require().
affects: >=6.0.0
breakinggraphqlToSparql() method removed in v6.0.0: Only graphqlToSparqlAlgebra is available.
fix
Use graphqlToSparqlAlgebra() which returns SPARQL algebra object instead of string.
affects: >=6.0.0
gotchaArguments are converted to triple objects (not filters). String arguments become typed literals.
fix
Ensure argument values are properly escaped and typed if using non-string types.
affects: *
Errors
Common errors & fixes
TypeError: graphqlToSparql is not a function
graphqlToSparql() was removed in v6.0.0.
fix
Use graphqlToSparqlAlgebra() which returns algebra object.
Uncaught SyntaxError: Cannot use import statement outside a module
Using import without setting type: module in package.json or using .mjs extension.
fix
Set 'type': 'module' in package.json or rename file to .mjs.
Upgrade
Version history
6.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
graphql-to-sparql — npm install graphql-to-sparql · libregistry