Sha256: fdd13309ca8d2026ae3250bd09cdfea7488445f1b5e85e57cf385c5c0ae4621b

Contents?: true

Size: 1.36 KB

Versions: 4

Compression:

Stored size: 1.36 KB

Contents

module Ecoportal
  module API
    class GraphQL
      module Query
        class LocationStructure < Ecoportal::API::GraphQL::Logic::Query
          accepted_params :id
          accepted_params :includeArchivedNodes, default: true

          field_name :structure

          class_resolver :item_class, Ecoportal::API::GraphQL::Model::LocationStructure

          private

          def basic_block(&block)
            final_block = block || default_query_block
            Proc.new {
              query(id: :id!, includeArchivedNodes: :boolean) {
                currentOrganization {
                  locations {
                    structure(id: :id, &final_block)
                  }
                }
              }
            }
          end

          # At the moment it always retrieves archived nodes!!
          # @note this is on purpose, as via API
          #   there isn't much sense in not including archived nodes.
          def default_query_block
            Proc.new {
              id
              name
              archived
              weight
              updatedAt
              visitorManagementEnabled
              nodes(includeArchived: :includeArchivedNodes) {
                ___Ecoportal__API__GraphQL__Fragment__LocationNode
              }
            }
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ecoportal-api-graphql-0.3.13 lib/ecoportal/api/graphql/query/location_structure.rb
ecoportal-api-graphql-0.3.12 lib/ecoportal/api/graphql/query/location_structure.rb
ecoportal-api-graphql-0.3.11 lib/ecoportal/api/graphql/query/location_structure.rb
ecoportal-api-graphql-0.3.10 lib/ecoportal/api/graphql/query/location_structure.rb