-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add queryable interfaces #30
Conversation
🦋 Changeset detectedLatest commit: 09ad631 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work @rubensworks ! I'm really happy to hear that everything seems to work as intended. I have a few comments but only one of them is significant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! I wouldn't merge, yet, but looks good.
No indeed, won't merge yet. Just published |
I've removed the filterable interfaces from this PR for now into #31, since no implementations of this interface exist yet, and it may take a longer time to stabilize. This PR has been open for a week now. |
Pinging some people who may want to have another look at this: @gsvarovsky @tpluscode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize I come late to the party, since I was not actively participating in this PR. Sorry if you might find my comment a little disruptive of your effort.
I envisioned that I would have an immediate use for it but I gotta share some observations. My biggest beef is with the Bindings
interface. Please see the individual code comments
query/queryable.d.ts
Outdated
> = unknown | ||
& (SupportedResultType extends BindingsResultSupport ? { | ||
queryBindings<QueryFormatType extends QueryFormatTypesAvailable>( | ||
query: QueryFormatType, | ||
context?: QueryFormatType extends string ? QueryStringContextType : QueryAlgebraContextType, | ||
): Promise<ResultStream<Bindings>>; | ||
} : unknown) | ||
& (SupportedResultType extends BooleanResultSupport ? { | ||
queryBoolean<QueryFormatType extends QueryFormatTypesAvailable>( | ||
query: QueryFormatType, | ||
context?: QueryFormatType extends string ? QueryStringContextType : QueryAlgebraContextType, | ||
): Promise<boolean>; | ||
} : unknown) | ||
& (SupportedResultType extends QuadsResultSupport ? { | ||
queryQuads<QueryFormatType extends QueryFormatTypesAvailable>( | ||
query: QueryFormatType, | ||
context?: QueryFormatType extends string ? QueryStringContextType : QueryAlgebraContextType, | ||
): Promise<ResultStream<RDF.Quad>>; | ||
} : unknown) | ||
& (SupportedResultType extends VoidResultSupport ? { | ||
queryVoid<QueryFormatType extends QueryFormatTypesAvailable>( | ||
query: QueryFormatType, | ||
context?: QueryFormatType extends string ? QueryStringContextType : QueryAlgebraContextType, | ||
): Promise<void>; | ||
} : unknown) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyone else finds the queryX
methods names a little awkward?
If this is a SPARQL query interface, how about renaming them to their query form counterparts? For example as they are called in sparql-http-client
> = unknown | |
& (SupportedResultType extends BindingsResultSupport ? { | |
queryBindings<QueryFormatType extends QueryFormatTypesAvailable>( | |
query: QueryFormatType, | |
context?: QueryFormatType extends string ? QueryStringContextType : QueryAlgebraContextType, | |
): Promise<ResultStream<Bindings>>; | |
} : unknown) | |
& (SupportedResultType extends BooleanResultSupport ? { | |
queryBoolean<QueryFormatType extends QueryFormatTypesAvailable>( | |
query: QueryFormatType, | |
context?: QueryFormatType extends string ? QueryStringContextType : QueryAlgebraContextType, | |
): Promise<boolean>; | |
} : unknown) | |
& (SupportedResultType extends QuadsResultSupport ? { | |
queryQuads<QueryFormatType extends QueryFormatTypesAvailable>( | |
query: QueryFormatType, | |
context?: QueryFormatType extends string ? QueryStringContextType : QueryAlgebraContextType, | |
): Promise<ResultStream<RDF.Quad>>; | |
} : unknown) | |
& (SupportedResultType extends VoidResultSupport ? { | |
queryVoid<QueryFormatType extends QueryFormatTypesAvailable>( | |
query: QueryFormatType, | |
context?: QueryFormatType extends string ? QueryStringContextType : QueryAlgebraContextType, | |
): Promise<void>; | |
} : unknown) | |
> = unknown | |
& (SupportedResultType extends BindingsResultSupport ? { | |
select<QueryFormatType extends QueryFormatTypesAvailable>( | |
query: QueryFormatType, | |
context?: QueryFormatType extends string ? QueryStringContextType : QueryAlgebraContextType, | |
): Promise<ResultStream<Bindings>>; | |
} : unknown) | |
& (SupportedResultType extends BooleanResultSupport ? { | |
ask<QueryFormatType extends QueryFormatTypesAvailable>( | |
query: QueryFormatType, | |
context?: QueryFormatType extends string ? QueryStringContextType : QueryAlgebraContextType, | |
): Promise<boolean>; | |
} : unknown) | |
& (SupportedResultType extends QuadsResultSupport ? { | |
construct<QueryFormatType extends QueryFormatTypesAvailable>( | |
query: QueryFormatType, | |
context?: QueryFormatType extends string ? QueryStringContextType : QueryAlgebraContextType, | |
): Promise<ResultStream<RDF.Quad>>; | |
} : unknown) | |
& (SupportedResultType extends VoidResultSupport ? { | |
update<QueryFormatType extends QueryFormatTypesAvailable>( | |
query: QueryFormatType, | |
context?: QueryFormatType extends string ? QueryStringContextType : QueryAlgebraContextType, | |
): Promise<void>; | |
} : unknown) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was also a long discussion about this one here: rdfjs/query-spec#7
Eventually, we reached a consensus about the current methods.
(I don't remember the exact argumentation, perhaps @jacoscaz or @gsvarovsky knows?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do remember the argumentation but it originated from the question of whether to have these type-specific methods at all. Now that we do have them in the spec, this looks like an interesting change to me. Or at least I cannot come up with a strong argument against this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No strong opinion on this myself, I would be fine with this change. I think @gsvarovsky had some concerns about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm definitely in favour of more fluent method names. My only reservation is that these methods obtain a query object/proxy but don't execute it. But at this point that's probably splitting hairs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we all agree on having these methods return results directly, without an intermediate Query
object, then we might also agree on changing their names as per @tpluscode's suggestion. Anyone against this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just remembered a (significant) reason to keep the query...
methods: interface discovery through autocompletion.
Since the Queryable
interface already exposes a query
method, developers that don't need the API docs might start typing query...
in their editor. Smart editors would then immediately also suggest queryBindings
, queryQuads
, ... This would help developers get directed to the simpler query methods from the SparqlQueryable
interface if they are available.
If we would go for select
, construct
, etc, then we have to take into account the fact that construct
might cause some confusion, since we don't have a 1-1 mapping with the SPARQL query clauses. Namely, construct
would be used for both CONSTRUCT
and DESCRIBE
query clauses, which may not be obvious for newcomers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, if were to go with renaming to select
, construct
, ... then we should also have a describe
, which in the majority of cases would probably call construct
internally. I guess on one side we would favor discovery by autocompletion, on the other side we would favor discovery by intuition. I can see the point in both approaches, happy to go with either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another (minor) argument in favor of query...
is the alignment with the resultType
field of Query
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All told, there seem to be more arguments in favor of keeping these methods as they are. I think we can resolve this and proceed with merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closing thought: for a large PR with many new pieces, it would be wise to add some tests :)
@@ -0,0 +1,13 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha! This will be the real last comment. Should the pre
take be removed or are you intending another prerelease?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, will remove.
Right, will look into that. |
I just added some tests (I didn't aim for full coverage though, just the most critical parts for now) |
…es provided as algebra objects in comments
…on a specific algebra implementation
Modularizes Queryable and SparqlQueryable interfaces
All issues should be resolved now. Unless there are any other comments, I'll merge this on Thursday (after fixing the changelog). |
This PR implements the latest state of the new query spec as defined in https://github.com/rdfjs/query-spec/
This PR should not be merged yet into master until the query spec is stable.
In the meantime, prereleases of this package are being published to npm for testing purposes.
At the time of writing
1.1.0-next.0
of@rdfjs/types
is available on npm.@jacoscaz I changed some small things while experimenting with these interfaces in Comunica. Nothing major was changed, just some things to simplify the implementation of them.
All interfaces (except for the filterable ones) have been implemented in Comunica, and have been confirmed to work as intended.