prez icon indicating copy to clipboard operation
prez copied to clipboard

[Feature] Configure custom endpoints to inject a dataset FROM clause in the generated query

Open ashleysommer opened this issue 7 months ago • 4 comments

Currently, Prez generates every query as a union graph query.

I'd like the ability to configure a "use this named graph" option per endpoint. (or more than one per endpoint). Eg:

  • for the /catalogs/ endpoint, I want to use the <http://example.com/dcat-g> named graph Generated query:
CONSTRUCT {
  ?focus_node <https://prez.dev/type> <https://prez.dev/FocusNode> .
  ?focus_node <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?prof_1_node_1
}
FROM <http://example.com/dcat-g>
WHERE {
  {
    SELECT DISTINCT ?focus_node
    WHERE {
      ?focus_node <http://purl.org/dc/terms/hasPart> ?path_node_1 .
      ?focus_node rdf:type <http://www.w3.org/ns/dcat#Catalog> .
      ?path_node_1 rdf:type <http://www.w3.org/ns/dcat#Dataset>
    } LIMIT 10 OFFSET 0
  }
  ?focus_node <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?prof_1_node_1
}
  • for the /catalogs/{cat-id}/collections/ endpoint I want to use the <http://example.com/dcat-g> and <http://example.com/vocabs> and <http://example.com/meta> named graphs:
CONSTRUCT {
  ?focus_node <https://prez.dev/type> <https://prez.dev/FocusNode> .
  ?focus_node <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?prof_1_node_1
}
FROM <http://example.com/dcat-g>
FROM <http://example.com/vocabs>
FROM <http://example.com/meta>
WHERE {
  { 
    SELECT DISTINCT ?focus_node
    WHERE {
      <http://example.com/catalogs/datasets> dcterms:hasPart ?focus_node .
      <http://example.com/catalogs/datasets> rdf:type <http//www.w3.org/ns/dcat#Catalog> .
      ?focus_node rdf:type <http://www.w3.org/ns/dcat#Dataset>
    }  LIMIT 10 OFFSET 0
  }
  ?focus_node <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?prof_1_node_1
}

ashleysommer avatar May 21 '25 06:05 ashleysommer

I don't think this would be too hard. What's a sensible name for a query param - probably graphs?

recalcitrantsupplant avatar May 22 '25 01:05 recalcitrantsupplant

I don't think it woudl be a query param. I think it would be something you'd configure in the custom-endpoints file. It would be set up by an admin, for each different endpoint.

ashleysommer avatar May 26 '25 02:05 ashleysommer

Right yes I think this would be fine in terms of not breaking anything, I do note in the case of custom queries for object endpoints, as these are just read in as (close to) strings, where those are used, you'd need to update those queries directly, and then for listing endpoints update the custom endpoints file. So it fragments how the dataset is configured in that scenario unfortunately.

recalcitrantsupplant avatar May 26 '25 03:05 recalcitrantsupplant

I do note in the case of custom queries for object endpoints, as these are just read in as (close to) strings, where those are used, you'd need to update those queries directly, and then for listing endpoints update the custom endpoints file.

Yeah, I realize that too, but I think thats okay. I think the very slim numbers of users writing custom queries for object endpoints would be happy to accept that.

ashleysommer avatar May 26 '25 08:05 ashleysommer