Sha256: bc8759e15067bfc8f4b51a0a166175d8fe9e64bc621f82414fceaa7d3a56e192

Contents?: true

Size: 626 Bytes

Versions: 2

Compression:

Stored size: 626 Bytes

Contents

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

    # Should probably be in graphiti itself
    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
graphiti_graphql-0.1.1 lib/graphiti_graphql/util.rb
graphiti_graphql-0.1.0 lib/graphiti_graphql/util.rb