Destination types
On this page
Comunica SPARQL supports update queries to add, delete, or change data on both the command line and when calling Comunica from a JavaScript application.
Update queries typically consists of two parts:
- Query pattern to select data from a source;
- Quads to add or delete based on the query pattern into a destination.
In most cases, the source and destination are equal, such as when modifying data in an in-memory RDF/JS Store.
Since Comunica decouples source and destination, it is possible to read data from one place, and apply changes in another place.
Usually, destinations are passed as URLs that point to Web resources. Based on what is returned when dereferencing this URL, Comunica can apply different update algorithms.
Instead of relying on Comunica's detection algorithms, you can enforce the use of a certain type.
sparql
type MUST be set.
info
logger,
you can derive what type Comunica has determined for each destination.
Setting destination type on the command line
Destination types can optionally be enforced by prefixing the URL with <typeName>@
, such as
$ comunica-sparql https://example.org/file-in.ttl \ --to patchSparqlUpdate@https://example.org/file-out.ttl \ "INSERT DATA { <ex:s> <ex:p> <ex:o> }"
Setting destination type in an application
Via a JavaScript application,
the destination type can be set by using a hash containing type
and value
:
await myEngine.queryVoid(`...`, { sources: [ { type: 'file', value: 'https://example.org/file-in.ttl' }, ], destination: { type: 'patchSparqlUpdate', value: 'https://example.org/file-out.ttl' }, });
Supported destination types
The table below summarizes the different destination types that Comunica supports by default:
Type name | Description |
---|---|
rdfjsStore | JavaScript objects implementing the RDF/JS store interface |
sparql | SPARQL endpoint |
putLdp | Linked Data Platform HTTP APIs accepting PUT requests containing an RDF document, such as Solid servers. |
patchSparqlUpdate | Linked Data Platform HTTP APIs accepting PATCH requests containing SPARQL Update queries (application/sparql-update ), such as Solid servers. |
The default source type is auto
,
which will automatically detect the proper source type.
For example, if an Accept-Patch: application/sparql-update
header
is detected, the patchSparqlUpdate
type is used.