Repository navigation
fix: Support BGPs with variables in SPARQL UPDATE queries - #786
Conversation
rubensworks
left a comment
There was a problem hiding this comment.
Looks good! Just some thoughts that are probably better for a separate PR.
| import type { Readable } from 'stream'; | ||
| import type { ActorInitSparql } from '@comunica/actor-init-sparql'; | ||
| import { newEngine } from '@comunica/actor-init-sparql'; | ||
| import type { IQueryResultUpdate } from '@comunica/actor-init-sparql/lib/ActorInitSparql-browser'; |
There was a problem hiding this comment.
Oh, we probably want this one to be available in this export as well: https://github.com/comunica/comunica/blob/master/packages/actor-init-sparql/index.ts
| if (!(typeof op.where === 'undefined' || this.isBasicGraphPatternWithoutVariables(op.where))) { | ||
| this.logger.warn('WHERE statements are not supported'); | ||
| throw new NotImplementedHttpError('WHERE statements are not supported'); | ||
| if (!(typeof op.where === 'undefined' || op.where.type === Algebra.types.BGP)) { |
There was a problem hiding this comment.
Since it's possible to support other query types as well, why not expose a config option to just allow this? (perhaps via a separate PR?)
There was a problem hiding this comment.
Good point for the future; we want to avoid applications depending on this though as it's not cross-implementation.
There was a problem hiding this comment.
(Also begs the question of how to advertise that functionality.)
There was a problem hiding this comment.
we want to avoid applications depending on this though as it's not cross-implementation.
Ah yes, of course. The spec should be clear that client MUST NOT assume all servers have support for this, but that they MAY/SHOULD make use of it when they discover it.
(Also begs the question of how to advertise that functionality.)
Something like a profile for SPARQL Update media type in the Accept-Patch header may work here (but I would guess this has been suggested already in the Solid spec discussions).
| this.applyOperation(result, (patch as SparqlUpdatePatch).algebra); | ||
| // Run the query through Comunica | ||
| const sparql = await readableToString(patch.data); | ||
| const query = await this.engine.query(sparql, { sources: [ result ]}) as IQueryResultUpdate; |
There was a problem hiding this comment.
I guess this is not a problem in most cases, but for better performance, we may consider thinking about making Representation implement the RDFJS Store interface, so that it can be passed to the query engine directly.
d5a26c9 to
bfb888e
Compare
ed8ad54 to
a63f29d
Compare
a63f29d to
bac877a
Compare
Closes #784 and closes #15 (sort of).
Depends on #781.
The checks are there to make sure we only support BGP queries, but there's not really anything stopping us from allowing everything. At that point we could even remove the algebra body parser since we now only use it for validating.