Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@xantrac
Copy link
Contributor

@xantrac xantrac commented Jun 20, 2025

This PR allows the user to setup a new value bypass_all for the multitenancy option in the read action. With bypass_all the user can recursively bypass the tenancy of all the resources successively loaded.

Also this PR removes the bypass value from the other actions type since it wasn't actually implemented.

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

@xantrac xantrac marked this pull request as draft June 20, 2025 01:27
@zachdaniel
Copy link
Contributor

I like the idea, but I think we're going to have to do it with shared context. The tenant can be any value, so for all we know :bypass is a valid tenant value for some user.

@xantrac
Copy link
Contributor Author

xantrac commented Jun 20, 2025

I like the idea, but I think we're going to have to do it with shared context. The tenant can be any value, so for all we know :bypass is a valid tenant value for some user.

That makes sense

xantrac added 5 commits June 26, 2025 13:30
- reading the tenancy configuration from the shared context
- cascading the same configurations to the nested actions
@xantrac xantrac marked this pull request as ready for review June 27, 2025 02:41
@xantrac xantrac changed the title provide the tenant: :bypass option that can be configured at runtime Read Action multitenancy :bypass_all Jun 27, 2025
{:ok, %{query | tenant: nil, to_tenant: nil}}

:bypass_all ->
query = Ash.Query.set_context(query, %{shared: %{multitenancy: :bypass_all}})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using shared context means it will apply to all children, regardless of how deep they are nested. Is this the intent? IIRC you made a good point about it being less confusing if it only extends to direct relationships.

Copy link
Contributor Author

@xantrac xantrac Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I think that was uncertain and you wanted this type of behavior. I think it can be confusing in both ways.

This pattern grew on me because it could be easier to debug knowing the all the descending queries will be untenanted instead of having to check each intermediate step. You know you users better so I'll leave the final decision to you.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way is better πŸ‘Œ

@xantrac xantrac requested a review from zachdaniel June 27, 2025 19:19
@zachdaniel zachdaniel merged commit e5f5105 into ash-project:main Jun 27, 2025
43 checks passed
@zachdaniel
Copy link
Contributor

πŸš€ Thank you for your contribution! πŸš€

@xantrac
Copy link
Contributor Author

xantrac commented Jun 27, 2025

πŸš€ Thank you for your contribution! πŸš€

Always!

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