Sha256: 6c0672fac6101cb05babd1e9981a381b2556bec4f3ffdbd7a5066794c7342f5d

Contents?: true

Size: 707 Bytes

Versions: 2

Compression:

Stored size: 707 Bytes

Contents

# frozen_string_literal: true

module Osso
  module GraphQL
    module Resolvers
      class EnterpriseAccounts < BaseResolver
        type Types::EnterpriseAccount.connection_type, null: true

        def resolve(sort_column: nil, sort_order: nil)
          return Array(Osso::Models::EnterpriseAccount.find_by(domain: context_domain)) unless internal_authorized?

          accounts = Osso::Models::EnterpriseAccount

          accounts = accounts.order(sort_column.underscore => sort_order_sym(sort_order)) if sort_column && sort_order

          accounts.all
        end

        def sort_order_sym(order_string)
          order_string == 'ascend' ? :asc : :desc
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
osso-0.0.5.pre.lambda lib/osso/graphql/resolvers/enterprise_accounts.rb
osso-0.0.5.pre.kappa lib/osso/graphql/resolvers/enterprise_accounts.rb