Skip to content
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

Create dedicated simplifySparqlResultsOneVariable function #114

Open
EdJoPaTo opened this issue Mar 28, 2023 · 1 comment
Open

Create dedicated simplifySparqlResultsOneVariable function #114

EdJoPaTo opened this issue Mar 28, 2023 · 1 comment

Comments

@EdJoPaTo
Copy link
Contributor

Currently simplifySparqlResults(sparqlResults, {minimize: bool}) exists.

The problem here is that the minimize argument only works when the query returns exactly one variable. If that's not the case the minimize argument is ignored.

if (vars.length === 1 && options.minimize === true) {

This means that the return type is not clear at compile time and only at runtime. Therefore TypeScript can not help much here. This could be more strict with either an error in case of more than one variable or (better in my opinion) a dedicated function for this.

This will be breaking either way.

@EdJoPaTo
Copy link
Contributor Author

EdJoPaTo commented Mar 28, 2023

Maybe even remove the richVal logic? Having the exact names of variables as in the query is also simple and results in way less checks / assumptions of the returning data.

richVal Logic Explanation:

When simplifySparqlResults finds variables which start the same (like item, itemLabel, itemDescription, …) they get combined into their own Record<suffix, SparqlValueRaw>. This results in the type being Record<name, ValueRaw | Record<suffix, ValueRaw>> which is not that simple anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant