Module: Decidim::Core::HasLocalizedInputFilter

Included in:
ComponentInputFilter
Defined in:
decidim-core/lib/decidim/api/input_filters/has_localized_input_filter.rb

Class Method Summary collapse

Class Method Details

.included(child_class) ⇒ Object


6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'decidim-core/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