Sha256: 9bd938f6a060f4a11bcdb92542cf7ca6a499164c0b58295f518dd73faff08a5b

Contents?: true

Size: 879 Bytes

Versions: 12

Compression:

Stored size: 879 Bytes

Contents

module Ecoportal
  module API
    class GraphQL
      module Base
        class Connection < Ecoportal::API::GraphQL::Base::Model
          class GenericNode
            def initialize(*args, **kargs)
              raise "Missuse error. You should define a node_class for a class that inherits from GraphqlConnection class."
            end
          end

          include Enumerable

          class_resolver :node_class, GenericNode

          passthrough :edges
          passthrough :totalCount
          embeds_many :nodes, klass: :node_class
          embeds_one :pageInfo, klass: Ecoportal::API::GraphQL::Base::PageInfo

          def empty?
            count < 1
          end

          def each(&block)
            return to_enum(:each) unless block
            nodes.each(&block)
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ecoportal-api-graphql-0.1.11 lib/ecoportal/api/graphql/base/connection.rb
ecoportal-api-graphql-0.1.10 lib/ecoportal/api/graphql/base/connection.rb
ecoportal-api-graphql-0.1.9 lib/ecoportal/api/graphql/base/connection.rb
ecoportal-api-graphql-0.1.8 lib/ecoportal/api/graphql/base/connection.rb
ecoportal-api-graphql-0.1.7 lib/ecoportal/api/graphql/base/connection.rb
ecoportal-api-graphql-0.1.6 lib/ecoportal/api/graphql/base/connection.rb
ecoportal-api-graphql-0.1.5 lib/ecoportal/api/graphql/base/connection.rb
ecoportal-api-graphql-0.1.4 lib/ecoportal/api/graphql/base/connection.rb
ecoportal-api-graphql-0.1.3 lib/ecoportal/api/graphql/base/connection.rb
ecoportal-api-graphql-0.1.2 lib/ecoportal/api/graphql/base/connection.rb
ecoportal-api-graphql-0.1.1 lib/ecoportal/api/graphql/base/connection.rb
ecoportal-api-graphql-0.1.0 lib/ecoportal/api/graphql/base/connection.rb