Sha256: 70cb6bb1d7ea74acb743e44a69cad7ae29cd6c72acc1f17a2bee5eea1d150c34

Contents?: true

Size: 1.78 KB

Versions: 1

Compression:

Stored size: 1.78 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
            #ap = access_point(path)
            request(*path, "contractorEntities") do
              graphql_query(**kargs, &basic_block(&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

1 entries across 1 versions & 1 rubygems

Version Path
ecoportal-api-graphql-0.1.4 lib/ecoportal/api/graphql/query/contractor_entities.rb