Skip to content

SPARQL example: authentication, named graphs, and recent connections in the connection dialog - #172

Open
kvistgaard wants to merge 3 commits into
reactodia:masterfrom
kvistgaard:feat/sparql-connection-dialog
Open

SPARQL example: authentication, named graphs, and recent connections in the connection dialog#172
kvistgaard wants to merge 3 commits into
reactodia:masterfrom
kvistgaard:feat/sparql-connection-dialog

Conversation

@kvistgaard

Copy link
Copy Markdown

SPARQL example: authentication, named graphs, and recent connections in the connection dialog

Summary

Extends the connection dialog in the sparql example (the playground) so an
endpoint that is not open and unrestricted can be explored without writing code:

  • HTTP Basic authentication — optional username/password, sent as an
    Authorization header via the existing
    SparqlDataProviderOptions.queryFunction extension point. No library changes.
  • Named graph restriction — one or more graph IRIs, applied as SPARQL 1.1
    Protocol default-graph-uri parameters (§2.1.4), so all queries see the merge
    of the listed graphs instead of the whole dataset.
  • Recent connections — each successful connection (endpoint, graphs,
    username) is remembered in localStorage, listed in the dialog, and refills
    the form on click. Up to 8, deduplicated, removable.

Motivation for the graph restriction

Exploring a whole endpoint stops working once the endpoint is large: on
knowledge graphs with billions of triples the class tree and statistics queries
aggregate over everything the store holds, which is slow at best and a timeout
at worst — and the result mixes every dataset on the endpoint. Restricting the
dataset to named graphs makes such endpoints usable from the playground:

  • exploration scopes to one dataset on a shared endpoint that hosts many;
  • class counts and link statistics describe the dataset of interest instead of
    the union of unrelated graphs;
  • a data graph can be combined with its ontology graph when the schema (class
    and property declarations, labels, hierarchy) is stored separately — without
    it there are no link types to display;
  • no server-side configuration is needed, where the alternative is a dedicated
    restricted endpoint per dataset.

Handling of credentials

  • Passwords are kept in tab-scoped sessionStorage only: they survive a reload,
    die with the tab, and never enter the URL hash or the recent-connections list.
  • Stored credentials are keyed to the endpoint they were entered for and are
    attached only when the hash names that endpoint, so a pasted link to a
    different endpoint can never receive them.
  • Clicking a recent connection that used a username focuses the (deliberately
    empty) password field, so the missing value is visible before Connect.
  • The endpoint and graph IRIs stay in the URL hash as before, so a configuration
    remains a bookmarkable link. The hash is now written once per save and parsed
    from location.href rather than location.hash, whose getter returns a
    percent-decoded value in Firefox and would corrupt endpoint URLs containing
    encoded & or =. Graph IRIs split on whitespace only, since a comma is a
    legal IRI character.

Testing

Driven end-to-end in headless Chromium against a mock endpoint requiring Basic
auth (every request carried the header and the graph parameters, before and
after reload, and credentials stored for one endpoint are not attached to
another) and against a Virtuoso 08.03.3332 endpoint holding an 11M-triple named
graph (restriction verified by comparing type-instance counts with and without
the graph parameters). npm run lint, npm run typecheck, and the examples
build pass.

🤖 Generated with Claude Code

kvistgaard and others added 3 commits August 26, 2026 17:48
- Optional HTTP Basic authentication via a custom queryFunction;
  credentials are kept in tab-scoped session storage, keyed to their
  endpoint, and never enter the URL hash.
- Optional restriction of all queries to one or more named graphs via
  SPARQL Protocol default-graph-uri parameters.
- Recently used connections (endpoint, graphs, username) persisted in
  local storage, refilling the form on click.
- Write the URL hash once per save and parse it from location.href,
  whose fragment is not percent-decoded by Firefox unlike location.hash.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A named connection is pinned: it is never evicted from the list, while
unnamed ones rotate through the most recent few. Activating an entry
connects directly when no credentials are needed, otherwise it fills
the form and focuses the password field.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A connection restored from a bookmarked or shared URL now lands in the
saved connections list the same as one submitted through the dialog,
which previously was the only way an entry was recorded.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant