Ash FrameworkAF
Ash Framework3mo ago
9 replies
Shahryar

How to `multitenancy :bypass` of nested/normal load

Hi, if i have a relation that has read_action which call the function which has multitenancy :bypass, i get this error
     ** (Ash.Error.Invalid)
     Bread Crumbs:
       > Error returned from: MishkaDocument.Section.read

     Invalid Error

     * Queries against the MishkaDocument.Section resource require a tenant to be specified

For example:
# :master_get is multitenancy :bypass
fetched_section = Ash.get!(Section, section.id, action: :master_get, authorize?: false)
section_with_workspace =
          Ash.load!(fetched_section, [master_workspace_version: :master_workspace],
            # tenant: fetched_section.site_id,
            authorize?: false
          )


Relation:
    belongs_to :master_workspace_version, MishkaDocument.WorkspaceVersion do
      public? true
      source_attribute :workspace_version_id
      destination_attribute :id
      read_action :read_any

      description "The workspace version this section belongs to (master admin access, bypass tenant)"
    end


This :read_any inside MishkaDocument.WorkspaceVersion is
read :read_any do
      multitenancy :bypass
      description "Reads all versions bypassing tenant filtering (for master relationships)"
      pagination offset?: true, default_limit: 20, max_page_size: 100, countable: true
    end

How can bypass it?
Thank you in advance
Solution
So set action: :master_read on the load call as well
Was this page helpful?