Skip to content

Commit

Permalink
handler-fetch: upgrade oxigraph to 0.4.0-rc.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ludovicm67 committed Aug 27, 2024
1 parent 21d81bc commit 7d6a17a
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/lazy-glasses-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trifid-handler-fetch": patch
---

Upgrade Oxigraph to 0.4.0-rc.1.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 19 additions & 7 deletions packages/handler-fetch/lib/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,31 @@ export const performOxigraphQuery = async (store, query) => {

try {
if (isConstructQuery) {
contentType = 'application/n-quads'
results = store.query(query, {
const queryResults = store.query(query, {
use_default_graph_as_union: true,
}).map((quad) => quad.toString()).join('.\n')
if (results) {
results = `${results}.\n`
})
if (Array.isArray(queryResults)) {
contentType = 'application/n-quads'
results = queryResults.map((quad) => quad.toString()).join('.\n')
if (results) {
results = `${results}.\n`
}
} else {
contentType = 'text/plain'
results = 'Something went wrong while getting the query results (expected array).'

Check warning on line 33 in packages/handler-fetch/lib/query.js

View check run for this annotation

Codecov / codecov/patch

packages/handler-fetch/lib/query.js#L32-L33

Added lines #L32 - L33 were not covered by tests
}
} else {
contentType = 'application/sparql-results+json'
results = store.query(query, {
const queryResults = store.query(query, {
use_default_graph_as_union: true,
results_format: 'json',
})
if (typeof queryResults === 'string') {
contentType = 'application/sparql-results+json'
results = queryResults
} else {
contentType = 'text/plain'
results = 'Something went wrong while getting the query results (expected string).'
}

Check warning on line 46 in packages/handler-fetch/lib/query.js

View check run for this annotation

Codecov / codecov/patch

packages/handler-fetch/lib/query.js#L44-L46

Added lines #L44 - L46 were not covered by tests
}
} catch (error) {
contentType = 'text/plain'
Expand Down
2 changes: 1 addition & 1 deletion packages/handler-fetch/lib/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const handleConfig = async (config) => {
store.load(data, {
format: contentType,
base_iri: baseIri,
to_named_graph: graphNameIri,
to_graph_name: graphNameIri,
})
parentPort.postMessage({
type: 'log',
Expand Down
2 changes: 1 addition & 1 deletion packages/handler-fetch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"prepack": "npm run build"
},
"dependencies": {
"oxigraph": "^0.4.0-alpha.7",
"oxigraph": "^0.4.0-rc.1",
"uuid": "^10.0.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/handler-fetch/test/handler-fetch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('trifid-handler-fetch', () => {
`, {
format: 'text/turtle',
base_iri: 'http://example.org/',
to_named_graph: oxigraph.defaultGraph(),
to_graph_name: oxigraph.defaultGraph(),
})
})

Expand Down

0 comments on commit 7d6a17a

Please sign in to comment.