Class: HasHelpers::Resolvers::UserApplicationOrder

Inherits:
Base
  • Object
show all
Defined in:
app/graphql/has_helpers/resolvers/user_application_order.rb

Constant Summary collapse

SKIP_APP_ACCESS_CHECK =
true

Instance Method Summary collapse

Methods included from Middleware::ApplicationAccess

#authorized?

Instance Method Details

#resolve(**_args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/graphql/has_helpers/resolvers/user_application_order.rb', line 11

def resolve(**_args)
  uo = HasHelpers::UserOrganization.find_by(
    user_id: current_user.id,
    organization_id: current_organization.id
  )

  Array(uo&.applications_array).map.with_index(1) do |app_name, index|
    application = HasHelpers::Application.find_by(name: app_name)

    next unless application

    link = application.url

    next if link.blank?

    {
      name: application.name,
      link: link,
      priority: index
    }
  end.compact
end