Sha256: 922286a62fc45afddc1693da538b7403ad48c7c472901e36acf2cceac3b05f3d
Contents?: true
Size: 1.13 KB
Versions: 9
Compression:
Stored size: 1.13 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 < GraphQL::Function 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
9 entries across 9 versions & 1 rubygems