Sha256: 61481f3a852e7060946c86ec14e710b54280d1fa0511ce6dc4d5e87f4e515516
Contents?: true
Size: 1.11 KB
Versions: 37
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true module Decidim module Core # An abstract class with the logic for the GraphQL endpoint for a single component to be searchable. # Normal components (such as Proposal) can inherit from this class and just # add the needed search arguments # # Usually something like: # # class ProposalFinderHelper < Decidim::Core::ComponentFinderBase # argument :id, !types.ID, "The ID of the proposal" # end # # For an example check # decidim-proposals/app/types/decidim/proposals/proposals_type.rb class ComponentFinderBase attr_reader :model_class def initialize(model_class:) @model_class = model_class end def call(component, args, _ctx) @query = { component: component } args.keys.each do |key| @query[key] = args[key] end query_scope.find_by(@query) end # By default, any model in its defaul scope # Particular implementations may restrict this by adding # additional constrains def query_scope model_class end end end end
Version data entries
37 entries across 37 versions & 1 rubygems