Module: GraphitiGql::SortExtras

Defined in:
lib/graphiti_gql/graphiti_hax.rb

Overview

Below is all to support pagination argument ‘last’

Instance Method Summary collapse

Instance Method Details

#sort_paramObject



489
490
491
492
493
494
495
496
497
498
499
500
501
502
# File 'lib/graphiti_gql/graphiti_hax.rb', line 489

def sort_param
  param = super
  if query_hash[:reverse]
    param = [{ id: :asc }] if param == []
    param = param.map do |p|
      {}.tap do |hash|
        dir = p[p.keys.first]
        dir = dir == :asc ? :desc : :asc
        hash[p.keys.first] = dir
      end
    end
  end
  param
end