Sha256: df3dcca168600ad504ef090fce7a55b0f1980f1037fc209587c98023cec38f56

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

module Ecoportal
  module API
    class GraphQL
      module Query
        class LocationStructures < Ecoportal::API::GraphQL::Logic::QueryArray
          accepted_params :includeArchived, :includeUnpublished
          field_name :structures

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

          private

          def basic_block(&block)
            final_block = block || default_query_block
            Proc.new {
              query(includeArchived: :boolean, includeUnpublished: :boolean) {
                currentOrganization {
                  locations {
                    structures(
                      includeArchived: :includeArchived,
                      includeUnpublished: :includeUnpublished,
                      &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
              visitorManagementEnabled
              nodes(includeArchived: true) {
                ___Ecoportal__API__GraphQL__Fragment__LocationNode
              }
            }
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ecoportal-api-graphql-0.3.8 lib/ecoportal/api/graphql/query/location_structures.rb