Sha256: 797686d2a425af1546860e76e2ea61c1264a5c40b602f716d96b6ee3479bc8e9

Contents?: true

Size: 1.9 KB

Versions: 4

Compression:

Stored size: 1.9 KB

Contents

module Ecoportal
  module API
    class GraphQL
      module Query
        class ContractorEntities < Ecoportal::API::GraphQL::Base::QueryConnection
          class_resolver :item_class, Ecoportal::API::GraphQL::Model::ContractorEntity
          class_resolver :connection_class, Ecoportal::API::GraphQL::Connection::ContractorEntity

          def query(path: default_base_path, **kargs, &block)
            path ||= default_base_path
            kargs = self.class.slice_params(kargs)
            ap = access_point(path)
            request(*path, "contractorEntities") do
              next client.query(kargs, &basic_block(&block)) if block_given?
              client.query(kargs, &basic_block)
            end
          end

          def default_base_path
            ["currentOrganization"]
          end

          private

          def basic_block(&block)
            connection_block = block || default_connection_block
            Proc.new {
              query(searchConf: :Search, after: :string, before: :string, first: :int, last: :int) {
                currentOrganization {
                  contractorEntities(
                    searchConf: :searchConf,
                    after: :after,
                    before: :before,
                    first: :first,
                    last: :last,
                    &connection_block
                  )
                }
              }
            }
          end

          def default_connection_block
            Proc.new {
              totalCount
              pageInfo {
                endCursor
              }
              nodes {
                id
                name
                schemaId
                active
                approved
                associatedPeopleIds
                leadContractorIds
              }
            }
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ecoportal-api-graphql-0.1.3 lib/ecoportal/api/graphql/query/contractor_entities.rb
ecoportal-api-graphql-0.1.2 lib/ecoportal/api/graphql/query/contractor_entities.rb
ecoportal-api-graphql-0.1.1 lib/ecoportal/api/graphql/query/contractor_entities.rb
ecoportal-api-graphql-0.1.0 lib/ecoportal/api/graphql/query/contractor_entities.rb