# @traqula/algebra-sparql-1-2

> Convert SPARQL to SPARQL algebra

Latest version **1.3.0** (published 2026-09-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install @traqula/algebra-sparql-1-2
pnpm add @traqula/algebra-sparql-1-2
yarn add @traqula/algebra-sparql-1-2
bun add @traqula/algebra-sparql-1-2
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2026-09-09 |
| First published | 2025-09-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 24 |
| Author | Jitse De Smet |
| Maintainers | rubensworks, jitsedesmet |

## Links

- npm: https://www.npmjs.com/package/@traqula/algebra-sparql-1-2
- Repository: https://github.com/comunica/traqula
- Homepage: https://github.com/comunica/traqula#readme
- Issues: https://github.com/comunica/traqula/issues
- npm.io page: https://npm.io/package/@traqula/algebra-sparql-1-2

## Recent versions

- 1.3.0 (latest) — 2026-09-09
- 1.1.7-alpha.0 (next) — 2026-07-07
- 1.2.2 — 2026-09-02
- 1.2.1 — 2026-08-27
- 1.2.0 — 2026-08-05
- 1.1.8 — 2026-07-09
- 1.1.7 — 2026-07-07
- 1.1.6 — 2026-06-19
- 1.1.5 — 2026-06-18
- 1.1.4 — 2026-06-10
- 1.1.3 — 2026-06-09
- 1.1.2 — 2026-06-05
- 1.1.1 — 2026-05-09
- 1.1.0 — 2026-04-29
- 1.0.7 — 2026-04-16
- … 30 more at https://npm.io/package/@traqula/algebra-sparql-1-2/versions

## README

<p align="center">
    <img alt="Traqula logo" width="70%" style="border-radius: 20px" src="../../assets/white-on-red/logo-white-on-red-lettered-social.png">
</p>

<p align="center">
  <strong>A query language transpiler framework for JavaScript</strong>
</p>

# SPARQL 1.2 AST, SPARQL 1.2 Algebra transformer

[![npm version](https://badge.fury.io/js/@traqula%2Falgebra-sparql-1-2.svg)](https://www.npmjs.com/package/@traqula/algebra-sparql-1-2)

Modular transformer to transform a SPARQL 1.2 AST generated by Traqula to SPARQL 1.2 algebra.
There is also support for 'non-algebra' entities such as ASK, FROM, etc.
to make sure the output contains all relevant information from the query.

## Installation

```bash
npm install @traqula/algebra-sparql-1-2
```

or

```bash
yarn add @traqula/algebra-sparql-1-2
```

## Import

Either through ESM import:

```javascript
import { toAst, toAlgebra } from '@traqula/algebra-sparql-1-2';
```

_or_ CJS require:

```javascript
const { toAst, toAlgebra } = require('@traqula/algebra-sparql-1-2');
```

## Usage

Input for the translation function should be a Traqula AST, by calling [Traqula parser](../parser-sparql-1-2).
Algebra operations are modeled as objects of the structure `{ name: string; input: Operation[] }`.
The transformation is detailed by [section 18.3 of the SPARQL 1.2 specification](https://www.w3.org/TR/sparql12-query/#translation).

The example bellow demonstrates this package usage where we parse a query string and transform it to algebra, from the algebra we will go back to a query string.
Note that unlike the AST level, we do not provide [round tripping](../generator-sparql-1-1/README.md#round-tripping-generation) on algebra level.

```typescript
import { Parser } from '@traqula/parser-sparql-1-2';
import { Generator } from '@traqula/generator-sparql-1-2';
import { toAlgebra, fromAlgebra } from '@traqula/algebra-sparql-1-2';
// Initialize required variables.
const parser = new Parser();
const generator = new Generator();
const query = `SELECT * { ?s ?p ?o }`;

const ast = parser.parse(query);
const algebra = toAlgebra(ast);

const generatedAst = toAst(algebra);
const generatedQuery = generator.generate(generatedAst);
```

The algebra transformer for SPARQL 1.2 is a modification of [the SPARQL 1.1 algebra transformer](../algebra-sparql-1-1); therefore, much of the documentation of that transformer holds here too.

---
_Source: https://npm.io/package/@traqula/algebra-sparql-1-2 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
