# @traqula/generator-sparql-1-1

> SPARQL 1.1 generator

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

## Install

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

## 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-04-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 24 |
| Maintainers | rubensworks, jitsedesmet |

## Links

- npm: https://www.npmjs.com/package/@traqula/generator-sparql-1-1
- 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/generator-sparql-1-1

## Recent versions

- 1.3.0 (latest) — 2026-09-09
- 1.1.7-alpha.0 (next) — 2026-07-07
- 0.0.1-alpha.10 (canary) — 2025-08-18
- 1.2.1 — 2026-08-27
- 1.2.0 — 2026-08-05
- 1.1.8 — 2026-07-09
- 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
- 1.0.6 — 2026-04-09
- … 34 more at https://npm.io/package/@traqula/generator-sparql-1-1/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>

# Traqula SPARQL 1.1 generator

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

Traqula Generator SPARQL 1.1 is a [SPARQL 1.1](https://www.w3.org/TR/sparql11-query/#grammar) query generator for TypeScript.
It can generate SPARQL given the AST created by [Traqula parser SPARQL 1.1](https://github.com/comunica/traqula/tree/main/engines/parser-sparql-1-1).

## Installation

```bash
npm install @traqula/generator-sparql-1-1
```

or

```bash
yarn add @traqula/generator-sparql-1-1
```

## Import

Either through ESM import:

```javascript
import { Generator } from '@traqula/generator-sparql-1-1';
```

_or_ CJS require:

```javascript
const Generator = require('@traqula/generator-sparql-1-1').Generator;
```

## Usage

This package contains a `Generator` that is able to generate SPARQL 1.1 queries:

```typescript
import { Parser } from '@traqula/parser-sparql-1-1';
import { Generator } from '@traqula/generator-sparql-1-1';
const query = `SELECT * WHERE { ?s ?p ?o }`
const parser = new Parser();
const ast = parser.parse(query)

const generator = new Generator();
const queryString = generator.generate(ast);
```

Note that a single generator cannot generate multiple queries in parallel.

## Configuration

Optionally, the following parameters can be set in to the generator:

* `astFactory`: A custom AstFactory that is able to create the various AST nodes. _(default: `new AstFactory`)_
* `indentInc`: the number of spaces the built-in 'pretty print' mode must print for a single indentation level. _(default: `2`)_.
* `origSource`: the original query string the ast is constructed from.
* `[traqulaIndentation]` from `@traqula/core`: the current number of spaces to print on a newline.
Whenever this number is negative, no newline will be printed. _(default: 0)_
* `[traqulaNewlineAlternative]` from `@traqula/core`: the character that should be printed instead of a newline in case `[traqulaIndentation]` is negative. _(default: ' ')_

> [!note]
> To create a generator without pretty print:
> ```typescript
> import { Generator } from '@traqula/generator-sparql-1-1';
> import { traqulaIndentation } from '@traqula/core';
> const flatGenerator = new Generator({
>   indentInc: 0,
>   [traqulaIndentation]: -1,
> })
> ```

## Round-tripping generation

By default, the generator will emit the round tripped query string where possible.
In order to create an AST that supports round-tripping, you should make sure the [parser is set up correctly](../parser-sparql-1-1/README.md#collecting-round-tripping-information).

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