Sha256: 6e5f29379d22e4e27c960a176ca5c7050d7f33ab518145d294a0dc37892d4179

Contents?: true

Size: 627 Bytes

Versions: 15

Compression:

Stored size: 627 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

15 entries across 15 versions & 1 rubygems

Version Path
graphiti_graphql-0.1.17 lib/graphiti_graphql/util.rb
graphiti_graphql-0.1.16 lib/graphiti_graphql/util.rb
graphiti_graphql-0.1.15 lib/graphiti_graphql/util.rb
graphiti_graphql-0.1.14 lib/graphiti_graphql/util.rb
graphiti_graphql-0.1.12 lib/graphiti_graphql/util.rb
graphiti_graphql-0.1.11 lib/graphiti_graphql/util.rb
graphiti_graphql-0.1.10 lib/graphiti_graphql/util.rb
graphiti_graphql-0.1.9 lib/graphiti_graphql/util.rb
graphiti_graphql-0.1.8 lib/graphiti_graphql/util.rb
graphiti_graphql-0.1.7 lib/graphiti_graphql/util.rb
graphiti_graphql-0.1.6 lib/graphiti_graphql/util.rb
graphiti_graphql-0.1.5 lib/graphiti_graphql/util.rb
graphiti_graphql-0.1.4 lib/graphiti_graphql/util.rb
graphiti_graphql-0.1.3 lib/graphiti_graphql/util.rb
graphiti_graphql-0.1.2 lib/graphiti_graphql/util.rb