Bypassing multitenancy directly from code interfaces

I know there is the multitenancy :bypass option for read actions but is it possible to pass it as an option in code interfaces as well? Something like this or similar is what I'm looking for:
Lamashka.Establishments.get_establishment(
est_id,
scope: conn.assigns.scope, # only actor data available
tenant: :bypass
)
Lamashka.Establishments.get_establishment(
est_id,
scope: conn.assigns.scope, # only actor data available
tenant: :bypass
)
7 Replies
ZachDaniel
ZachDaniel4mo ago
No, and we likely wouldn't add it TBH But there is an option that just allows bypassing tenancy IIRC As opposed to always bypassing Just lets you not specify a tenant
Joan Gavelán
Joan GavelánOP4mo ago
That would be cool, that way I don't have to create yet another action(s) just to bypass tenancy
ZachDaniel
ZachDaniel4mo ago
I think it's like multitenancy :allow_global Like that goes in the action, not as an option I mean Just allows calling the action with or without a tenant
Joan Gavelán
Joan GavelánOP4mo ago
Mm I think that still requires me to create additional actions just to bypass tenancy? I find myself doing this
read :list_establishments do
multitenancy :bypass
end

read :get_establishment do
get_by :id
multitenancy :bypass
end
read :list_establishments do
multitenancy :bypass
end

read :get_establishment do
get_by :id
multitenancy :bypass
end
I think a better approach - for this resource at least - is to enable it directly from the multitenancy block with the global? option
Joan Gavelán
Joan GavelánOP4mo ago
No description
Joan Gavelán
Joan GavelánOP4mo ago
Yeah that allows me to reuse the interfaces that I had defined inline without creating additional actions
define :list_establishments, action: :read
define :get_establishment, action: :read, get_by: :id
define :list_establishments, action: :read
define :get_establishment, action: :read, get_by: :id
Appreciate the assist this late, Zach — peak support right there
ZachDaniel
ZachDaniel4mo ago
I think you can do it per action with multitenancy :allow_global in the action you want to allow global But doing it at the resource level works too

Did you find this page helpful?