Skip to content

StreamStore: add default URL parameter for the default graph #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions StreamStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class StreamStore {

if (graph && graph.termType !== 'DefaultGraph') {
url.searchParams.append('graph', graph.value)
} else {
url.searchParams.append('default', '')
}

const res = await this.client.fetch(url, {
Expand Down Expand Up @@ -97,6 +99,8 @@ class StreamStore {

if (graph && graph.termType !== 'DefaultGraph') {
url.searchParams.append('graph', graph.value)
} else {
url.searchParams.append('default', '')
}

const serialize = new Transform({
Expand Down
5 changes: 4 additions & 1 deletion test/StreamStore.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ describe('StreamStore', () => {
})
})

it('should not send the graph query parameter if the default graph is requested', async () => {
it('should send the default parameter if the default graph is requested', async () => {
await withServer(async server => {
let defaultParameter = null
let graphParameter = null

server.app.get('/', async (req, res) => {
defaultParameter = req.query.default
graphParameter = req.query.graph

res.status(204).end()
Expand All @@ -101,6 +103,7 @@ describe('StreamStore', () => {
const stream = store.read({ method: 'GET', graph: rdf.defaultGraph() })
await chunks(stream)

strictEqual(defaultParameter, '')
strictEqual(graphParameter, undefined)
})
})
Expand Down