Class: Decidim::Api::Types::BaseMutation
- Inherits:
-
GraphQL::Schema::RelayClassicMutation
- Object
- GraphQL::Schema::RelayClassicMutation
- Decidim::Api::Types::BaseMutation
- Includes:
- GraphqlPermissions, FormFactory
- Defined in:
- lib/decidim/api/types/base_mutation.rb
Instance Method Summary collapse
- #available_locales ⇒ Object
- #current_component ⇒ Object
- #current_organization ⇒ Object
- #current_user ⇒ Object
- #set_locale(locale:, toggle_translations:) ⇒ Object
Instance Method Details
#available_locales ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/decidim/api/types/base_mutation.rb', line 35 def available_locales if current_organization.present? current_organization.available_locales else I18n.available_locales.map(&:to_s) end end |
#current_component ⇒ Object
27 28 29 |
# File 'lib/decidim/api/types/base_mutation.rb', line 27 def current_component context[:current_component] end |
#current_organization ⇒ Object
31 32 33 |
# File 'lib/decidim/api/types/base_mutation.rb', line 31 def current_organization context[:current_organization] end |
#current_user ⇒ Object
23 24 25 |
# File 'lib/decidim/api/types/base_mutation.rb', line 23 def current_user context[:current_user] end |
#set_locale(locale:, toggle_translations:) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/decidim/api/types/base_mutation.rb', line 16 def set_locale(locale:, toggle_translations:) raise I18n::InvalidLocale, "#{locale} is not a valid locale" unless available_locales.include?(locale) I18n.locale = locale.presence RequestStore.store[:toggle_machine_translations] = toggle_translations end |