Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ldkit/sparql.ts>sparql

LDkit - Linked Data query toolkit for TypeScript developers
Latest
variable sparql
import { sparql } from "https://deno.land/x/ldkit@2.0.0/sparql.ts";

A template tag for SPARQL queries or its parts. Automatically converts values to SPARQL literals and escapes strings as needed.

Examples

Example 1

import { sparql } from "ldkit/sparql";
import { DataFactory } from "ldkit/rdf";

const df = new DataFactory();
const quad = df.quad(
  df.namedNode("http://example.org/s"),
  df.namedNode("http://example.org/p"),
  df.literal("o"),
);
const query = sparql`SELECT * WHERE { ${quad} }`;
console.log(query); // SELECT * WHERE { <http://example.org/s> <http://example.org/p> "o" . }

type

(strings: TemplateStringsArray, ...values: SparqlValue[]) => string