Sha256: 27962443ae7442403e2656240b5c948795d59017806023c26bd246efa4034321

Contents?: true

Size: 1.29 KB

Versions: 14

Compression:

Stored size: 1.29 KB

Contents

module Ecoportal
  module API
    class GraphQL
      module Logic
        class QueryConnection < Ecoportal::API::GraphQL::Logic::Query
          accepted_params :searchConf, :after, :before, :first, :last
          include Enumerable

          def each(connection_block: nil, **kargs, &block)
            return to_enum(:each, **kargs, connection_block: connection_block) unless block
            cursor = nil; results = 0
            loop do
              kargs.update(after: cursor) if cursor
              connection = query(**kargs, &connection_block)
              #total    = connection.totalCount
              pageInfo = connection.pageInfo
              connection.nodes.each do |item|
                yield item
              end
              break unless cursor = pageInfo.endCursor
            end
          end

          def response_class
            return connection_class if respond_to?(:connection_class)
            @response_class ||= self.class.new_class(
              item_class,
              inherits: Ecoportal::API::GraphQL::Logic::Connection,
              namespace: "Ecoportal::API::GraphQL::Connection"
            ) do |klass|
              klass.item_class = item_class
            end
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
ecoportal-api-graphql-0.3.13 lib/ecoportal/api/graphql/logic/query_connection.rb
ecoportal-api-graphql-0.3.12 lib/ecoportal/api/graphql/logic/query_connection.rb
ecoportal-api-graphql-0.3.11 lib/ecoportal/api/graphql/logic/query_connection.rb
ecoportal-api-graphql-0.3.10 lib/ecoportal/api/graphql/logic/query_connection.rb
ecoportal-api-graphql-0.3.9 lib/ecoportal/api/graphql/logic/query_connection.rb
ecoportal-api-graphql-0.3.8 lib/ecoportal/api/graphql/logic/query_connection.rb
ecoportal-api-graphql-0.3.7 lib/ecoportal/api/graphql/logic/query_connection.rb
ecoportal-api-graphql-0.3.6 lib/ecoportal/api/graphql/logic/query_connection.rb
ecoportal-api-graphql-0.3.5 lib/ecoportal/api/graphql/logic/query_connection.rb
ecoportal-api-graphql-0.3.3 lib/ecoportal/api/graphql/logic/query_connection.rb
ecoportal-api-graphql-0.3.1 lib/ecoportal/api/graphql/logic/query_connection.rb
ecoportal-api-graphql-0.2.3 lib/ecoportal/api/graphql/logic/query_connection.rb
ecoportal-api-graphql-0.2.2 lib/ecoportal/api/graphql/logic/query_connection.rb
ecoportal-api-graphql-0.2.1 lib/ecoportal/api/graphql/logic/query_connection.rb