class Decidim::Core::ParticipatorySpaceListBase

An abstract base class resolver for the GraphQL endpoint for listing participatory spaces Inherit from this class and add search arguments to create list-finders participatory classes as is shown in ParticipatorySpaceList + info: github.com/rmosolgo/graphql-ruby/blob/v1.6.8/guides/fields/function.md

Attributes

manifest[R]

Public Class Methods

new(manifest:) click to toggle source
# File lib/decidim/api/functions/participatory_space_list_base.rb, line 15
def initialize(manifest:)
  @manifest = manifest
end

Public Instance Methods

call(_obj, args, ctx) click to toggle source
# File lib/decidim/api/functions/participatory_space_list_base.rb, line 24
def call(_obj, args, ctx)
  @query = model_class.public_spaces.where(
    organization: ctx[:current_organization]
  )

  add_filter_keys(args[:filter])
  add_order_keys(args[:order].to_h)
  add_default_order
  @query
end
model_class() click to toggle source

lazy instantation of the class

# File lib/decidim/api/functions/participatory_space_list_base.rb, line 20
def model_class
  @model_class ||= manifest.model_class_name.constantize
end