Skip to content

feat: Ability to save/load queries from sqlite file#395

Open
shaunpatterson wants to merge 3 commits into
dgraph-io:mainfrom
shaunpatterson:sp/preloaded_scripts
Open

feat: Ability to save/load queries from sqlite file#395
shaunpatterson wants to merge 3 commits into
dgraph-io:mainfrom
shaunpatterson:sp/preloaded_scripts

Conversation

@shaunpatterson
Copy link
Copy Markdown

Description

Gives the ability to save and load queries to a sqlite3 file.

Checklist

  • Code compiles correctly and linting passes locally
  • For all code changes, an entry added to the CHANGELOG.md file describing and linking to
    this PR
  • Tests added for new functionality, or regression tests for bug fixes added as applicable
  • For public APIs, new features, etc., PR on docs repo
    staged and linked here

shaunpatterson and others added 3 commits January 10, 2026 16:26
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>
@shaunpatterson shaunpatterson changed the title feat: Ability to save/load from sqlite file feat: Ability to save/load queries from sqlite file Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant