Repository navigation
Description
Versions
fluree-serverbuilt frommain@ commite40f5560c(PR rollup: Cumulative work from #1258, #1260, #1261, #1262, #1263 (mis-merged to solo/latest) #1264, merged 2026-06-01)- Linux x86_64, local single-node, default file storage
Summary
On the ledger-scoped POST /v1/fluree/query/{ledger} endpoint, a SPARQL query that walks named graphs via GRAPH <iri> { ... } returns empty bindings unless the same IRI is also listed in FROM NAMED <iri>. Most SPARQL endpoints (Virtuoso, Jena ARQ, RDF4J, Stardog, Blazegraph) expose all named graphs of the active database to GRAPH patterns by default — Fluree requires every name to be opted in by the caller.
This is technically permitted by SPARQL 1.1 §13.2 (the "active dataset" is server-defined), and the Fluree docs do hint at it. But every other engine I tested takes the friendlier default, and the failure mode here is silent: queries return bindings: [] with no warning that the named graph wasn't part of the dataset. Many existing SPARQL clients and dashboards (YASGUI, Wikidata UI patterns, etc.) generate GRAPH ?g { ?s ?p ?o } without any FROM NAMED, expecting to discover all named graphs from the endpoint.
Reproducer
# 1. Create + populate a ledger with one named graph
curl -X POST http://localhost:8090/v1/fluree/create \
-H 'Content-Type: application/json' \
-d '{"ledger":"ngquirk:main"}'
cat > /tmp/probe.trig <<'EOF'
@prefix ex: <http://example.org/probe/> .
GRAPH <urn:probegraph> {
ex:a ex:p ex:b .
ex:a ex:q "hello" .
}
EOF
curl -X POST http://localhost:8090/v1/fluree/upsert/ngquirk:main \
-H 'Content-Type: application/trig' --data-binary @/tmp/probe.trig
# 2. Query the named graph *without* FROM NAMED — returns empty
curl -s -X POST http://localhost:8090/v1/fluree/query/ngquirk:main \
-H 'Content-Type: application/sparql-query' \
-H 'Accept: application/sparql-results+json' \
-d 'SELECT ?s ?p ?o WHERE { GRAPH <urn:probegraph> { ?s ?p ?o } }'
# 3. Same query *with* FROM NAMED — returns the 2 triples
curl -s -X POST http://localhost:8090/v1/fluree/query/ngquirk:main \
-H 'Content-Type: application/sparql-query' \
-H 'Accept: application/sparql-results+json' \
-d 'SELECT ?s ?p ?o FROM NAMED <urn:probegraph>
WHERE { GRAPH <urn:probegraph> { ?s ?p ?o } }'
# 4. SELECT DISTINCT ?g over GRAPH ?g — also empty (no graph discovery possible
# without enumerating each name first)
curl -s -X POST http://localhost:8090/v1/fluree/query/ngquirk:main \
-H 'Content-Type: application/sparql-query' \
-H 'Accept: application/sparql-results+json' \
-d 'SELECT DISTINCT ?g WHERE { GRAPH ?g { ?s ?p ?o } }'Expected
Step 2 returns the same 2 bindings as step 3 — i.e., the named graphs of the ledger are visible to GRAPH patterns by default.
Step 4 discovers <urn:probegraph> (and any other named graph in the ledger).
Actual
Step 2: "bindings": []
Step 3: 2 bindings
Step 4: "bindings": []
Same behavior on the connection-scoped /v1/fluree/query endpoint when targeting one ledger via FROM <ledger>.
Real-world impact
- Federated SPARQL dashboards (YASGUI, RDF Browser, etc.) generate exploratory queries with
GRAPH ?g { ... }and show nothing on Fluree — users see empty results and assume no data was published. - A common pattern for multi-document ingestion is per-document named graphs (e.g. CAM publishes annotations under
<urn:cam:doc:NNN>); aggregation queries like "give me every concept tagged across all documents" (SELECT ?c WHERE { GRAPH ?g { ?c a skos:Concept } }) silently return nothing. - Forces every consumer to either (a) maintain its own list of named graph IRIs to inject via
FROM NAMED, or (b) query the ledger's graph registry first (separate round trip) and then build the dataset clause dynamically.
Suggested behavior
On /query/{ledger}, the active dataset should default to the ledger's default graph + all named graphs registered in that ledger. This matches the principle of least surprise and aligns with how Virtuoso/Jena/RDF4J behave on a single graph store.
Caller-supplied FROM / FROM NAMED would still narrow / override this default, preserving the existing escape hatch.
Discovery / docs gap
The current behavior is referenced in docs/api/endpoints.md (the /query/{ledger} section) but as a feature, not a constraint. A short note like:
Without an explicit
FROM NAMED, the SPARQL named graphs of the ledger are not part of the active dataset —GRAPHpatterns will return empty. To query a named graph, addFROM NAMED <graph-iri>.
would help users diagnose this without an issue.
Workaround used downstream
Two patterns work:
# Pattern A — `FROM` makes the named graph the default for triple patterns
SELECT ?s ?p ?o FROM <urn:probegraph> WHERE { ?s ?p ?o }
# Pattern B — `FROM NAMED` makes the graph addressable via GRAPH
SELECT ?s ?p ?o
FROM NAMED <urn:probegraph>
WHERE { GRAPH <urn:probegraph> { ?s ?p ?o } }For dynamic dashboards we hit GET /info/{ledger} (or /ledgers) first, enumerate the named graphs, then inject all of them as FROM NAMED clauses before sending the user's query.
Activity
fix: resolve ledger named graphs in single-db GRAPH patterns (fluree#…
docs(audit): add Stage-1 burn-down cluster audits (8 deep-dive delive…
test(sparql): harden update-eval oracle per PR #1437 review
docs(query): unbound GRAPH ?g enumerates named graphs only (D-2)
fix(query): bind GRAPH ?g as an IRI term and stop enumerating the def…