feat: Ability to save/load queries from sqlite file#395
Open
shaunpatterson wants to merge 5 commits into
Open
Conversation
Add support for preloading common DQL queries from a YAML configuration file. Users can select queries from a "Templates" dropdown in the query editor, fill in variable placeholders via a modal dialog, and execute directly. Features: - YAML config file with queries, categories, and variable definitions - Templates dropdown grouped by category in EditorPanel - Variable substitution modal with validation for required fields - Support via --preloaded-queries flag or RATEL_PRELOADED_QUERIES env var - Example config file with common Dgraph query patterns Server changes: - New /api/preloaded-queries endpoint serving JSON from YAML config - Type definitions in server/preloaded.go - Added gopkg.in/yaml.v3 dependency Client changes: - Redux actions/reducer for preloaded queries state - PreloadedQueryDropdown and PreloadedQueryModal components - Integration into EditorPanel Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace read-only YAML-based preloaded queries with a full CRUD system using SQLite for persistent, user-editable saved queries. Changes: - Add SQLite database for saved queries (modernc.org/sqlite, pure Go) - Add REST API endpoints for CRUD operations - Add SavedQueriesDropdown with edit/delete functionality - Add SaveQueryModal for saving/editing queries - Add Save button to EditorPanel - Remove all YAML/preloaded query code API endpoints: - GET /api/saved-queries - List all queries - POST /api/saved-queries - Create new query - PUT /api/saved-queries/:id - Update query - DELETE /api/saved-queries/:id - Delete query Usage: - Set RATEL_QUERIES_DB=/path/to/queries.db or --queries-db flag - SQLite file can be committed to repo for team sharing Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add documentation for RATEL_QUERIES_DB env var and --queries-db flag - Create CHANGELOG.md documenting the saved queries feature - Fix: selecting a query now loads without auto-running - Fix: dropdown closes after selecting or editing a query - Add Go server tests for saved queries CRUD operations - Add Redux reducer and actions tests for saved queries - Add dev proxy for API calls during local development - Default DB path now uses OS temp directory (cross-platform) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
This PR has had no activity for 60 days and has been marked stale. Comment to keep it active. |
Address code-review findings on the saved-queries feature: - Remove unreachable `queriesDBPath == ""` branches and the always-true init guard; the DB and routes now register unconditionally. - Default the DB to the per-user config dir (persistent) instead of the temp dir, which the OS can wipe; fall back to temp only if unavailable. - Distinguish 404 (missing) from 500 (lookup failed) in PUT/DELETE via a requireQuery helper instead of swallowing the DB error. - Add writeJSONError + decodeQueryInput helpers (with a 1 MiB body cap) to drop repeated error-encoding and decode/validate boilerplate. - Drop the unused GET-by-id handler branch and misleading route comment. - Dedup default-value logic via SavedQueryInput.applyDefaults. - Reducer: hoist byCategoryThenName + EMPTY_SAVE_FORM; remove dead loadQueryToEditor duplicate. - Update docs to reflect the persistent default DB location. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Gives the ability to save and load queries to a sqlite3 file.
Checklist
CHANGELOG.mdfile describing and linking tothis PR
staged and linked here