Provide a native SPARQL client (comment if interested)

Created on 10 October 2024, 2 months ago

Problem/Motivation

SPARQL is a nice way to query RDF data across the web. With External Entities v3, new categories of storage clients where defined and one of them is the "QueryLanguageClientBase". It is used as base for the SQL storage client but the SQL storage client requires an extra module to work and therefore has been added as a companion module (xnttsql). There are no other example implementation of the "QueryLanguageClientBase" while a SPARQL client could be one. Furthermore, implementing such a client would help improve the design of "QueryLanguageClientBase" to better identify what could be common or not between query language clients before that API could be considered stable and widely usable for other client implementations.

Proposed resolution

I am not a SPARQL expert and I don't know much about it so I would need (expert) help on the design and the implementation.
What I think we would need on the storage client config form would be:

  • the SPARQL endpoint URL
  • the prefix to use for id field (eg. "wd")
  • the SPARQL SELECT query to fetch one or more entries with a "" placeholder to tell where to put ids. For example:
    SELECT ?item ?itemLabel WHERE {
      VALUES ?item { <id> }
      SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
    }

    where "" could be replaced by "wd:Q378619" to load a single entity or "wd:Q378619 wd:Q498787 wd:Q677525" to load multiple entities at once for instance.

  • maybe a mapping interface between Drupal field names and their corresponding SPARQL "prefix" or field name? (ie. a filter mapping section similar to the one used by xnttsql that could become part of the "QueryLanguageClientInterface")
  • maybe a placeholder list interface to associate <placeholders> in the query with other SPARQL queries used to retrieve the value when the external entity type is saved and avoid running such queries all the time (ie. cache the result and include it statically in the queries)

From the given SPARQL query, I believe it should be possible to automatically add filters for search queries as well as turn it into a "count" query using some kind of regexp. Maybe some structural constraints should be added to the query to have it supported by the storage client? What do SPARQL users think?
A query building interface could be possible but it would require too much work. I would see it as a layer above a simple SPARQL storage client module, just like I did with the SQL database storage client with the Chado Light module that hides the SQL query generation behind the scene while the SQL client exposes raw SQL queries.

Remaining tasks

Discuss, design and implement if it's a need.

User interface changes

None.

API changes

"QueryLanguageClientBase" may be changed.

Data model changes

None.

If you are interested by such a storage client, please post a comment here or follow the issue to help me measure if it is something that should be implemented as part of xntt v3 or not.

Feature request
Status

Active

Version

3.0

Component

Code

Created by

🇫🇷France guignonv

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024