Class: Mutations::UserPreferences::Update
- Inherits:
-
BaseMutation
- Object
- GraphQL::Schema::RelayClassicMutation
- BaseMutation
- Mutations::UserPreferences::Update
- Defined in:
- app/graphql/mutations/user_preferences/update.rb
Constant Summary collapse
- NON_NULLABLE_ARGS =
[ :extensions_marketplace_opt_in_status, :organization_groups_projects_display, :visibility_pipeline_id_type, :use_work_items_view, :merge_request_dashboard_list_type ].freeze
Constants inherited from BaseMutation
Constants included from Gitlab::Graphql::Authorize::AuthorizeResource
Gitlab::Graphql::Authorize::AuthorizeResource::ConfigurationError, Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR
Instance Method Summary collapse
Methods inherited from BaseMutation
#api_user?, authorization, authorization_scopes, authorized?, authorizes_object?, #current_user, #errors_on_object, #load_application_object, #read_only?, #ready?, #unauthorized_object
Methods included from Gitlab::Graphql::Authorize::AuthorizeResource
#authorize!, #authorized_find!, #authorized_resource?, #find_object, #raise_resource_not_available_error!
Instance Method Details
#resolve(**attributes) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'app/graphql/mutations/user_preferences/update.rb', line 60 def resolve(**attributes) attributes.delete_if { |key, value| NON_NULLABLE_ARGS.include?(key) && value.nil? } if attributes.include?(:extensions_marketplace_opt_in_status) attributes[:extensions_marketplace_opt_in_url] = ::WebIde::ExtensionMarketplace.marketplace_home_url(user: current_user) end user_preferences = current_user.user_preference if attributes[:work_items_display_settings].present? existing_settings = user_preferences.work_items_display_settings attributes[:work_items_display_settings] = existing_settings.merge(attributes[:work_items_display_settings]) end user_preferences.update(attributes) { user_preferences: user_preferences.valid? ? user_preferences : nil, errors: errors_on_object(user_preferences) } end |