summaryrefslogtreecommitdiff
path: root/app/graphql/mutations/user_preferences
diff options
context:
space:
mode:
Diffstat (limited to 'app/graphql/mutations/user_preferences')
-rw-r--r--app/graphql/mutations/user_preferences/update.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/app/graphql/mutations/user_preferences/update.rb b/app/graphql/mutations/user_preferences/update.rb
new file mode 100644
index 00000000000..c92c6d725b7
--- /dev/null
+++ b/app/graphql/mutations/user_preferences/update.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+module Mutations
+ module UserPreferences
+ class Update < BaseMutation
+ graphql_name 'UserPreferencesUpdate'
+
+ argument :issues_sort, Types::IssueSortEnum,
+ required: false,
+ description: 'Sort order for issue lists.'
+
+ field :user_preferences,
+ Types::UserPreferencesType,
+ null: true,
+ description: 'User preferences after mutation.'
+
+ def resolve(**attributes)
+ user_preferences = current_user.user_preference
+ user_preferences.update(attributes)
+
+ {
+ user_preferences: user_preferences.valid? ? user_preferences : nil,
+ errors: errors_on_object(user_preferences)
+ }
+ end
+ end
+ end
+end