Sha256: 60ff3e1ccb2942fed91986ed2c42cf5136300516f30021e1cf9bc2b4103688d8

Contents?: true

Size: 713 Bytes

Versions: 6

Compression:

Stored size: 713 Bytes

Contents

# frozen_string_literal: true

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

        def resolve(sort_column: nil, sort_order: nil)
          return Array(Osso::Models::EnterpriseAccount.find_by(domain: context[:scope])) if context[:scope] != :admin

          accounts = Osso::Models::EnterpriseAccount

          accounts = accounts.order(sort_column => 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

6 entries across 6 versions & 1 rubygems

Version Path
osso-0.0.3.16 lib/osso/graphql/resolvers/enterprise_accounts.rb
osso-0.0.3.15 lib/osso/graphql/resolvers/enterprise_accounts.rb
osso-0.0.3.14 lib/osso/graphql/resolvers/enterprise_accounts.rb
osso-0.0.3.13 lib/osso/graphql/resolvers/enterprise_accounts.rb
osso-0.0.3.12 lib/osso/graphql/resolvers/enterprise_accounts.rb
osso-0.0.3.11 lib/osso/graphql/resolvers/enterprise_accounts.rb