cubiql
cubiql copied to clipboard
language fall back problem
Language fall back does work properly:
- When
:schema-label-language en
and dataset label = no language The query return no results:
{cubiql{
datasets {
title
uri
}
}}
The SPARQL produced is:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX qb: <http://purl.org/linked-data/cube#>
PREFIX dcterms: <http://purl.org/dc/terms/>
SELECT ?ds ?name ?title ?description ?licence ?issued ?modified ?publisher WHERE {
{ SELECT DISTINCT ?ds WHERE { ?ds a qb:DataSet .} }
?ds <http://www.w3.org/2000/01/rdf-schema#label> ?name .
FILTER(LANG(?name) = "en")}
- When
:schema-label-language en
and measureProperty language = en The query return no label for measures although there is a label with@en
{cubiql{
dataset_employment {
measures {
enum_name
label
uri
}
}}}
The result is:
{
"data": {
"cubiql": {
"dataset_employment": {
"measures": [
{
"enum_name": "COUNT",
"label": null,
"uri": "http://statistics.gov.scot/def/measure/count"
}
]
}
}
}
}
The SPARQL created is:
PREFIX qb: <http://purl.org/linked-data/cube#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?mt ?label WHERE {
<http://statistics.gov.scot/data/employment> qb:structure ?struct .
?struct qb:component ?comp .
?comp qb:measure ?mt .
?mt a qb:MeasureProperty .
OPTIONAL {
?mt <http://www.w3.org/2000/01/rdf-schema#label> ?label .
FILTER(LANG(?label) = "") }}
@zeginis - The schema-label-language
configuration option and label fallback behaviour is only used when locating the labels used to generate the GraphQL schema. When actually querying for labels the language has to match exactly. Not specifying a language means only literals without a language will be returned. Applying the fallback behaviour when querying could be confusing since e.g. lang_preference: "de"
would return german and english labels along with any without a language tag.
Would you prefer the fallback behaviour to apply when querying? Or would you like a different fallback behaviour (.e.g just the matching language and any literals without a language)?
@lkitching I thought that the language fallback worked also for querying, but it is ok.
However the point 2 is a bug then.
When :schema-label-language en and measureProperty language = en The query return no label for measures although there is a label with @en
@zeginis - If you don't specify a lang_preference
in the GraphQL query it will only match labels with no language, so
{cubiql{
dataset_employment {
measures {
enum_name
label
uri
}
}}}
would not match labels with an en
language tag.
The query
{ cubiql(lang_preference: "en") { ... } }
should return the label.
Would you prefer it if the default returned all labels if no lang_preference
is specified?
I see so lang_preference: "en"
is for querying and :schema-label-language en
is to build the schema.
What do you mean with "all labels"? E.g. if there are en
and de
labels return both of them as an array including their language tag?
@zeginis - Yes, the lang_preference
parameter defines which language to fetch the results in. The schema-label-language
and fallback behaviour is only used to find the labels used to build the GraphQL schema.
By "all labels" I meant we could return a list of all the labels for each dimension/measure, but thinking about it this might not be a great idea since we only expect a single label for each language and would require a change to the schema. We could apply the fallback behaviour in the case of no lang_preference
being specified though i.e. schema-label-language
-> en
-> no language tag
?
I agree that "all labels" is not a good option.
Yes we could apply also the fall back at querying using the order you mention.