Add query parameter support for read actions#5
Closed
Munksgaard wants to merge 3 commits intoagentjido:mainfrom
Closed
Add query parameter support for read actions#5Munksgaard wants to merge 3 commits intoagentjido:mainfrom
Munksgaard wants to merge 3 commits intoagentjido:mainfrom
Conversation
Add query parameter support to generated Jido read actions: - JidoAction struct: query_params? (default: true), max_page_size fields - AllActions struct: read_query_params? (default: true), read_max_page_size - DSL: new options for action and all_actions entities - Transformer: propagates new fields for read actions - Generator: appends filter/sort/limit/offset/load params to read schemas via new build_query_params_schema/1 helper - Tests: 7 new tests covering schema generation and opt-out behavior - Updated existing tests to reflect new default query param presence
Update the :read case in the generated action's execute_action/4 to: - Split query params (filter/sort/limit/offset/load) from action args before passing to Ash.Query.for_read - Apply query opts via individual Ash.Query functions using Enum.reduce - Use filter_input/sort_input (safe variants) for security - Enforce max_page_size by clamping limit values Helper functions added inside the quoted block: - split_query_params/2: separates query params from action params - enforce_max_page_size/2: caps limit to configured max - apply_query_opts/2: applies each query option to the Ash query Also makes test User attributes public (required for filter_input). 13 new runtime integration tests covering: - Filter: equality, greater_than, in, multiple conditions (AND) - Sort: ascending, descending - Pagination: limit, offset, combined - Combined: filter + sort + limit - max_page_size enforcement (clamp + within bounds) - Backward compat: empty params
Add Query Parameters section to README.md with: - Available parameters overview (filter, sort, limit, offset, load) - Usage example - Security note (filter_input/sort_input safe variants) - Configuration examples (query_params?, max_page_size) - Updated action options and all_actions options tables - Removed 'pagination or query-layer magic' from 'What It Does Not Do' Add Querying and Filtering section to guides/getting-started.md with: - Filter syntax (equality, operators, multiple conditions, IN) - Sort syntax (keyword list and string formats) - Pagination (limit + offset) - Dynamic relationship loading - Combined example - Configuration reference
Munksgaard
added a commit
to Munksgaard/ash_jido
that referenced
this pull request
Apr 1, 2026
Unify PR agentjido#5 (Munksgaard) and PR agentjido#7 (barnabasJ) approaches: - Rename action_parameters -> query_params (per-action DSL option) - Rename read_action_parameters -> read_query_params (all_actions DSL option) - Add Query Parameters section to README.md with examples and config - Add Querying and Filtering section to getting-started.md guide - Update DSL option tables in both docs - Remove 'Add pagination or query-layer magic' from What It Does Not Do Keeps PR agentjido#7's core logic: compile-time field validation, string key support, map-based sort format, and ash_json_api-style type checks. Uses PR agentjido#5's naming convention and documentation style. All 186 tests pass. mix quality clean.
Contributor
|
Superseded by #15, which landed the read-action query parameter support on April 1, 2026 with follow-up fixes for tool-style string-key params and JSON sort payloads. |
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.
Problem
Generated Jido read actions had no way to filter, sort, or paginate results. An LLM agent calling ListUsers would always get back every record with no ability to narrow results — making read tools impractical for any non-trivial dataset.
Solution
Read actions now accept optional filter, sort, limit, offset, and load parameters that map directly to Ash's query API. These appear in the action's NimbleOptions schema (and therefore in the JSON Schema that LLMs see), so agents can discover and use them through normal tool calling.
Example usage
Security
Query parameters use Ash's safe input variants — Ash.Query.filter_input/2 and Ash.Query.sort_input/2 — which only permit filtering and sorting on public attributes and honor field policies. Private or internal fields cannot be accessed through these parameters.
Configuration
Enabled by default for read actions. Can be controlled per-action or globally:
Changes
ad6b1be — DSL options and schema generation
1359b24 — Runtime execution
dadcd12 — Documentation
Test coverage
20 new tests across schema generation and runtime execution:
All 182 tests pass. mix quality clean (format, compile, credo, dialyzer).
Disclaimer
This PR was written by Claude, but I've looked through it and it seems reasonable.
It might be worth considering whether there should be some protection against misuse, but the language is rather limited, so aside from trying to load every related resource, I don't think there's much an attacker can do.
It might also be worth considering if this behavior should be opt-in rather than opt-out.
Fixes #4