Skip to content

Pass relationship read action arguments - #2775

Merged
zachdaniel merged 7 commits into
ash-project:mainfrom
jechol:read-action-arguments
Jul 18, 2026
Merged

Pass relationship read action arguments#2775
zachdaniel merged 7 commits into
ash-project:mainfrom
jechol:read-action-arguments

Conversation

@jechol

@jechol jechol commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Adds read_action_arguments to relationships and passes them through relationship loading.

Explicit loads can already provide arguments to read actions, but relationship definitions could only choose the read_action itself. This adds the missing symmetric piece: a relationship can now declare static arguments for that read action.

This is useful when a relationship should load through a specific read action with relationship-specific argument values, while still allowing explicitly provided load arguments to take precedence.

Includes coverage for a has_many relationship using a read action argument.

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

@zachdaniel

Copy link
Copy Markdown
Contributor

🤔 this is pretty complex. We'd want to survey the following places to make sure that they handle this when building related queries:

  • ash_postgres
  • ash_sql
  • ash_sqlite
  • ash_json_api
  • ash_graphql
  • ash_typescript

If they do any related query building then they'd have to be upgraded to use this option ideally before we release this. (i.e Map.get(relationship, :arguments, %{}))

@jechol
jechol force-pushed the read-action-arguments branch from 804dbc6 to b944191 Compare July 7, 2026 06:46
@jechol
jechol force-pushed the read-action-arguments branch from b944191 to 7d6ee6d Compare July 13, 2026 04:23
@jechol

jechol commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! I surveyed all six repositories.

Changes were needed in:

No changes were needed in ash_postgres, ash_sqlite, ash_json_api, or ash_typescript; they don't independently build related read-action queries from relationship metadata in the relevant paths.

The resulting precedence is:

  1. explicitly provided load/query arguments
  2. relationship read_action_arguments
  3. read action argument defaults

The extension changes use Map.get/3, so they remain compatible before the corresponding Ash version is released.

@jechol

jechol commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Quick status update:

So this should be ready for review whenever you have a chance. Thanks!

@zachdaniel
zachdaniel merged commit 96f1891 into ash-project:main Jul 18, 2026
43 of 49 checks passed
@zachdaniel

Copy link
Copy Markdown
Contributor

🚀 Thank you for your contribution! 🚀

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