netwerk-digitaal-erfgoed / network-of-terms

Search engine for finding terms in terminology sources (such as thesauri, classification systems and reference lists)
https://termennetwerk-api.netwerkdigitaalerfgoed.nl
European Union Public License 1.2
16 stars 3 forks source link

Use templates to generate queries #503

Open ddeboer opened 2 years ago

ddeboer commented 2 years ago

@mielvds suggested Grasp as a way for the Network of Terms to manage its SPARQL queries. Graph’s use case is different: a single GraphQL query results in a single SPARQL query, whereas in the NoT we have different queries per endpoint.

Still, the idea of using templates to generate SPARQL queries is interesting.

Pros

  1. We can move pre-processing from network-of-terms-api back to the catalog. This results in a better separation of concerns, as the catalog already knows about SPARQL endpoints. The API would no longer supply several query variants. Instead, the catalog calls the query variant functions as template functions.
  2. We can reduce duplication in queries, particularly between lookup and search queries that are usually very similar.
  3. Some operations that are impossible or very complex to express in plain SPARQL can be expressed in the template language.

Cons

  1. Flat .rq files are easy to debug and collaborate on with third parties. Collaborators need to understand the template language and the (TypeScript) functions called from the templates to see what’s going on.

@EnnoMeijers What do you think?

mielvds commented 2 years ago

If I may add to that:

EnnoMeijers commented 2 years ago

Interesting idea although it is a bit hard for me to get a clear picture of the end result and the benefits. I am a little concerned that implementing Grasp will have a major impact on the architecture and will introduce more complexity for the catalogue. Because the catalogue is the only part of the NoT were other parties will contribute to on a regular basis, we should avoid to much complexity there. But I might be wrong, I suggest we plan a meeting to discuss this idea and the possibility of a small exploration in this direction.