module Decidim::Core::HasLocalizedInputFilter

Public Class Methods

included(child_class) click to toggle source
# File lib/decidim/api/input_filters/has_localized_input_filter.rb, line 6
def self.included(child_class)
  child_class.argument :locale,
                       type: GraphQL::Types::String,
                       description: "Specify the locale to use when searching translated fields, otherwise default organization language will be used",
                       required: false,
                       prepare: lambda { |locale, ctx|
                         unless ctx[:current_organization].available_locales.include?(locale)
                           raise GraphQL::ExecutionError, "#{locale} locale is not used in the organization"
                         end

                         locale
                       }
end