@rdfc/sparql-ingest-processor-ts 2.1.2 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/Utils.js +6 -2
  2. package/package.json +1 -1
package/lib/Utils.js CHANGED
@@ -81,7 +81,11 @@ export async function doSPARQLRequest(query, config, logger) {
81
81
  const timeout = config.measurePerformance?.queryTimeout || 1800;
82
82
  if (query.length > 0 && typeof query[0] !== 'string') {
83
83
  const quads = query;
84
- const writer = new N3Writer({ format: "N-Quads" });
84
+ let hasQuads = config.targetNamedGraph !== undefined;
85
+ if (quads.some(q => !q.graph.equals(df.defaultGraph()))) {
86
+ hasQuads = true;
87
+ }
88
+ const writer = new N3Writer({ format: hasQuads ? "N-Quads" : "N-Triples" });
85
89
  const serialized = writer.quadsToString(quads);
86
90
  const url = new URL(config.graphStoreUrl);
87
91
  if (config.accessToken) {
@@ -92,7 +96,7 @@ export async function doSPARQLRequest(query, config, logger) {
92
96
  const res = await fetch(url.toString(), {
93
97
  method: "POST",
94
98
  headers: {
95
- 'Content-Type': 'application/n-quads',
99
+ 'Content-Type': hasQuads ? 'application/n-quads' : 'application/n-triples',
96
100
  },
97
101
  body: serialized,
98
102
  dispatcher: new Agent({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rdfc/sparql-ingest-processor-ts",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "description": "SPARQL Update function to be within RDF-Connect pipelines",
5
5
  "author": "Julián Rojas",
6
6
  "contributors": [