Background
The qonsole-rails gem embeds a SPARQL query console as a Rails engine. The functionality has been rewritten as a standalone Web Component in the @epimorphics/qonsole npm package, which removes the dependency on Rails, jQuery, Bootstrap, and several other gem dependencies.
This migration is blocked on epimorphics/qonsole#62 being approved and a v2 release published.
Acceptance criteria
References
Migrating from qonsole-rails to @epimorphics/qonsole
1. Remove the gem
In Gemfile, remove:
In config/routes.rb, remove:
mount QonsoleRails::Engine, at: '/qonsole'
You can also drop any gem dependencies that were only there for qonsole: font-awesome-rails, haml-rails, jquery-rails, jquery-datatables-rails, lodash-rails, modulejs-rails, and the faraday stack (unless used elsewhere).
2. Install the npm package
Add to .yarnrc.yml:
npmScopes:
epimorphics:
npmRegistryServer: "https://npm.pkg.github.com"
npmAuthToken: "YOUR_GITHUB_TOKEN"
Then:
yarn add @epimorphics/qonsole
Import it in your JS bundle entry point:
import '@epimorphics/qonsole'
3. Convert config/qonsole.json to HTML attributes
The gem loaded config/qonsole.json on the server. With the web component, you pass that same data as inline attributes. The page that previously rendered at /qonsole (via the mounted engine) becomes a simple HTML page you own:
<epi-qonsole
endpoints='{"default": "https://your-sparql-endpoint/sparql"}'
prefixes='{"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", ...}'
queries='[{"name": "Example query", "query": "SELECT * WHERE { ?s ?p ?o } LIMIT 10"}]'
></epi-qonsole>
4. Decide how to handle SPARQL query execution
This is the key architectural choice. The gem ran queries server-side through a Rails controller (which handled CORS, timeouts, and endpoint whitelisting). The npm component sends queries directly from the browser.
Option A — Direct to endpoint (simplest): Works if the SPARQL endpoint allows CORS from your domain. No backend needed.
Option B — Route through a thin Rails proxy (matches existing behaviour): Keep a minimal Rails action and wire it via a custom service property:
document.querySelector('epi-qonsole').service = {
execute(query, { url, format, success, error }) {
fetch('/sparql/query', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({ query, output: format, endpoint: url })
})
.then(r => r.text())
.then(success)
.catch(error)
}
}
Option B is worth doing if you need server-side endpoint validation (the gem had a whitelist check), want to keep credentials/endpoint URLs off the client, or need to preserve the Faraday retry/timeout behaviour.
5. Update styles
The gem used Bootstrap classes and global SCSS. The web component is shadow-DOM encapsulated — global styles won't bleed in. Use CSS custom properties on the element to match your brand:
epi-qonsole {
--qonsole-color: #333;
--qonsole-accent-color: #0056b3;
--qonsole-accent-text-color: #fff;
--qonsole-font-family: sans-serif;
}
Summary
|
qonsole-rails gem |
@epimorphics/qonsole |
| SPARQL query config |
config/qonsole.json |
HTML attributes |
| Query execution |
Rails controller + Faraday |
Browser fetch (or custom service) |
| Routing |
Mounted engine at /qonsole |
Your own page/route |
| Styling |
Bootstrap + global SCSS |
CSS custom properties |
| HTML markup |
Haml template from engine |
Just <epi-qonsole ...> |
| Endpoint security |
Server-side whitelist |
Must re-implement if needed (Option B above) |
Background
The
qonsole-railsgem embeds a SPARQL query console as a Rails engine. The functionality has been rewritten as a standalone Web Component in the@epimorphics/qonsolenpm package, which removes the dependency on Rails, jQuery, Bootstrap, and several other gem dependencies.This migration is blocked on epimorphics/qonsole#62 being approved and a v2 release published.
Acceptance criteria
gem 'qonsole_rails'removed fromGemfileconfig/routes.rb@epimorphics/qonsoleadded as a yarn dependencyconfig/qonsole.jsoncontent converted to<epi-qonsole>HTML attributes<epi-qonsole>wired to the proxy via a customserviceproperty (see migration guide Option B)font-awesome-rails,haml-rails,jquery-rails,jquery-datatables-rails,lodash-rails,modulejs-rails,faradaystack if not used elsewhere)References
Migrating from qonsole-rails to @epimorphics/qonsole
1. Remove the gem
In
Gemfile, remove:In
config/routes.rb, remove:You can also drop any gem dependencies that were only there for qonsole:
font-awesome-rails,haml-rails,jquery-rails,jquery-datatables-rails,lodash-rails,modulejs-rails, and thefaradaystack (unless used elsewhere).2. Install the npm package
Add to
.yarnrc.yml:Then:
Import it in your JS bundle entry point:
3. Convert
config/qonsole.jsonto HTML attributesThe gem loaded
config/qonsole.jsonon the server. With the web component, you pass that same data as inline attributes. The page that previously rendered at/qonsole(via the mounted engine) becomes a simple HTML page you own:4. Decide how to handle SPARQL query execution
This is the key architectural choice. The gem ran queries server-side through a Rails controller (which handled CORS, timeouts, and endpoint whitelisting). The npm component sends queries directly from the browser.
Option A — Direct to endpoint (simplest): Works if the SPARQL endpoint allows CORS from your domain. No backend needed.
Option B — Route through a thin Rails proxy (matches existing behaviour): Keep a minimal Rails action and wire it via a custom
serviceproperty:Option B is worth doing if you need server-side endpoint validation (the gem had a whitelist check), want to keep credentials/endpoint URLs off the client, or need to preserve the Faraday retry/timeout behaviour.
5. Update styles
The gem used Bootstrap classes and global SCSS. The web component is shadow-DOM encapsulated — global styles won't bleed in. Use CSS custom properties on the element to match your brand:
Summary
config/qonsole.json/qonsole<epi-qonsole ...>