Class: GraphitiGraphQL::Util

Inherits:
Object
  • Object
show all
Defined in:
lib/graphiti_graphql/util.rb

Class Method Summary collapse

Class Method Details

.parse_sort(raw) ⇒ Object

Should probably be in graphiti itself



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/graphiti_graphql/util.rb', line 12

def self.parse_sort(raw)
  if raw.is_a?(Array)
    sorts = []
    raw.each do |sort|
      sort = sort.symbolize_keys
      att = sort[:att].to_s.underscore
      att = "-#{att}" if [:desc, "desc"].include?(sort[:dir])
      sorts << att
    end
    sorts.join(",")
  else
    raw
  end
end

.with_gql_contextObject



3
4
5
6
7
8
9
# File 'lib/graphiti_graphql/util.rb', line 3

def self.with_gql_context
  original = Graphiti.context[:graphql]
  Graphiti.context[:graphql] = true
  yield
ensure
  Graphiti.context[:graphql] = original
end