TriplyDB / Yasgui

Yet Another Sparql GUI
https://yasgui.triply.cc
MIT License
178 stars 54 forks source link

[YASQE] Querying an in-browser SPARQL engine #197

Closed ptgolden closed 2 years ago

ptgolden commented 2 years ago

What would be the best way to integrate YASGUI with a graph database that works locally? That is, to respond to SPARQL queries from within JavaScript without sending an HTTP request? Oxigraph is an example of a graph database and SPARQL query engine that can be included in the browser via WebAssembly.

One way to accomplish this currently is to listen to the query event from yasqe, rebuild the query from the request data, and abort the default HTTP request. But this seems like something that could break in the future. For example, if fetch were used as the HTTP request library (#150). (Cancelling fetch requests is a bit more involved than calling .abort()).

GerwinBosch commented 2 years ago

Hello and thanks for your ticket.

We noticed as well that yasqe's interface suited for local graph instances. One way to do it would be to override yasqe.query with something like

const yasqe = new Yasqe(...)
yasqe.query = (yasqeInstance) => {
  const queryString = yasqeInstance.getValue()
  ...
  // When using Yasgui
  yasqeInstance.emit("queryResponse", jsonResponse);
  // When using Yasr
  yasr.setResults(jsonResults)
}
gtfierro commented 2 years ago

@GerwinBosch @ptgolden thanks for the quick response! This is a much cleaner solution than I had hacked together originally

GerwinBosch commented 2 years ago

@ptgolden I'm closing this issue as the problem seems to be resolved, please reopen if that is not the case.