@@ -2245,6 +2245,23 @@ export default {
22452245 isLikelySolidOrRdfSource(source : string ) {
22462246 return ! this .isLikelySparqlEndpointSource (source );
22472247 },
2248+ /**
2249+ * Infers query mode from canonical example filename prefixes so the sample
2250+ * picker remains stable even when files omit explicit # QueryMode metadata.
2251+ */
2252+ inferModeFromExampleId(exampleId : string ): QueryExecutionMode | null {
2253+ const normalizedId = exampleId .toLowerCase ();
2254+ if (
2255+ normalizedId .startsWith (" link-traversal-" ) ||
2256+ normalizedId .startsWith (" link-taversal-" )
2257+ ) {
2258+ return " solid-link-traversal" ;
2259+ }
2260+ if (normalizedId .startsWith (" solid-no-traversal-" )) {
2261+ return " solid-no-traversal" ;
2262+ }
2263+ return null ;
2264+ },
22482265 /**
22492266 * Determines the target query engine mode for an example query. Authors can
22502267 * explicitly pin a mode via `# QueryMode: <mode-id>` in the .rq file.
@@ -2253,6 +2270,7 @@ export default {
22532270 _queryText : string ,
22542271 sources : string [],
22552272 declaredMode ? : string ,
2273+ exampleId ? : string ,
22562274 ): QueryExecutionMode {
22572275 if (
22582276 declaredMode &&
@@ -2261,6 +2279,13 @@ export default {
22612279 return declaredMode as QueryExecutionMode ;
22622280 }
22632281
2282+ if (exampleId ) {
2283+ const modeFromName = this .inferModeFromExampleId (exampleId );
2284+ if (modeFromName ) {
2285+ return modeFromName ;
2286+ }
2287+ }
2288+
22642289 const endpointSourceCount = sources .filter ((source ) =>
22652290 this .isLikelySparqlEndpointSource (source ),
22662291 ).length ;
@@ -2283,6 +2308,7 @@ export default {
22832308 queryText : string ,
22842309 sources : string [],
22852310 mode : QueryExecutionMode ,
2311+ exampleId ? : string ,
22862312 ): ExampleQueryCategory {
22872313 if (mode === " solid-link-traversal" ) {
22882314 return " Solid query (link traversal)" ;
@@ -2291,13 +2317,32 @@ export default {
22912317 return " Solid query (no traversal)" ;
22922318 }
22932319
2320+ const normalizedId = (exampleId || " " ).toLowerCase ();
2321+ if (normalizedId .startsWith (" federated-" )) {
2322+ return " Federated query" ;
2323+ }
2324+
22942325 const hasServiceClause = / service\s * <[^ >] + >/ i .test (queryText );
22952326 const endpointSourceCount = sources .filter ((source ) =>
22962327 this .isLikelySparqlEndpointSource (source ),
22972328 ).length ;
2329+ const endpointHosts = new Set (
2330+ sources
2331+ .filter ((source ) => this .isLikelySparqlEndpointSource (source ))
2332+ .map ((source ) => this .normalizeSourceUrlForValidation (source ))
2333+ .map ((source ) => {
2334+ try {
2335+ return new URL (source ).host ;
2336+ } catch {
2337+ return " " ;
2338+ }
2339+ })
2340+ .filter ((host ) => host .length > 0 ),
2341+ );
22982342
22992343 if (
23002344 hasServiceClause ||
2345+ endpointHosts .size > 1 ||
23012346 endpointSourceCount > 1 ||
23022347 (endpointSourceCount === 1 && sources .length > 1 )
23032348 ) {
@@ -2576,8 +2621,14 @@ export default {
25762621 query ,
25772622 sources ,
25782623 declaredMode ,
2624+ rawName ,
2625+ );
2626+ const category = this .categorizeExampleQuery (
2627+ query ,
2628+ sources ,
2629+ mode ,
2630+ rawName ,
25792631 );
2580- const category = this .categorizeExampleQuery (query , sources , mode );
25812632 queries .push ({
25822633 id: rawName ,
25832634 name ,
@@ -2604,8 +2655,10 @@ export default {
26042655 );
26052656 if (! example ) return ;
26062657
2607- // Clone example sources so user edits never mutate the static sample list.
2608- this .currentQuery .sources = [... example .sources ];
2658+ // Link-traversal examples intentionally start with no explicit datasource.
2659+ // Comunica can derive traversal seeds from IRIs that appear in the query.
2660+ this .currentQuery .sources =
2661+ example .mode === " solid-link-traversal" ? [] : [... example .sources ];
26092662 this .currentQuery .query = example .query || " " ;
26102663 this .queryMode = example .mode ;
26112664 this .syncYasqeFromExternalQuery (this .currentQuery .query , {
0 commit comments