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!) { 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