Skip to content

Add query parameter support for read actions#15

Merged
mikehostetler merged 4 commits intomainfrom
codex/pr5-eval
Apr 1, 2026
Merged

Add query parameter support for read actions#15
mikehostetler merged 4 commits intomainfrom
codex/pr5-eval

Conversation

@mikehostetler
Copy link
Copy Markdown
Contributor

Summary

  • build on the original Add query parameter support for read actions #5 implementation for read-action query params
  • normalize string-key query params before validation/execution so tool-call payloads work
  • support JSON-style sort entries while preserving keyword-list and string sort formats

Validation

  • MIX_ENV=test mix test
  • mix quality

Supersedes #5, #7, and #11 for issue #4.

Munksgaard and others added 4 commits April 1, 2026 12:05
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
Copy link
Copy Markdown
Contributor

Hooray!

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.

2 participants