Sha256: e81ff7a5388649bd08a86ebe5f27bb7159fa8ee44a69776b853ddde14e3f7500

Contents?: true

Size: 1.65 KB

Versions: 7

Compression:

Stored size: 1.65 KB

Contents

module Ecoportal
  module API
    class GraphQL
      module Query
        class LocationStructures < Ecoportal::API::GraphQL::Logic::QueryArray
          accepted_params :includeArchived, :includeUnpublished, default: false
          accepted_params :includeArchivedNodes, default: true

          field_name :structures

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

          private

          def basic_block(&block)
            final_block = block || default_query_block
            proc {
              query(includeArchived: :boolean,
                    includeUnpublished: :boolean,
                    includeArchivedNodes: :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 {
              id
              name
              archived
              weight
              visitorManagementEnabled
              nodes(includeArchived: :includeArchivedNodes) {
                ___Ecoportal__API__GraphQL__Fragment__LocationNode
              }
            }
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ecoportal-api-graphql-0.4.3 lib/ecoportal/api/graphql/query/location_structures.rb
ecoportal-api-graphql-0.4.2 lib/ecoportal/api/graphql/query/location_structures.rb
ecoportal-api-graphql-0.4.1 lib/ecoportal/api/graphql/query/location_structures.rb
ecoportal-api-graphql-0.4.0 lib/ecoportal/api/graphql/query/location_structures.rb
ecoportal-api-graphql-0.3.16 lib/ecoportal/api/graphql/query/location_structures.rb
ecoportal-api-graphql-0.3.15 lib/ecoportal/api/graphql/query/location_structures.rb
ecoportal-api-graphql-0.3.14 lib/ecoportal/api/graphql/query/location_structures.rb