summaryrefslogtreecommitdiff
path: root/app/graphql/mutations/snippets/update.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/graphql/mutations/snippets/update.rb')
-rw-r--r--app/graphql/mutations/snippets/update.rb18
1 files changed, 15 insertions, 3 deletions
diff --git a/app/graphql/mutations/snippets/update.rb b/app/graphql/mutations/snippets/update.rb
index b6bdcb9b67b..8890158b0df 100644
--- a/app/graphql/mutations/snippets/update.rb
+++ b/app/graphql/mutations/snippets/update.rb
@@ -30,12 +30,16 @@ module Mutations
description: 'The visibility level of the snippet',
required: false
+ argument :files, [Types::Snippets::FileInputType],
+ description: 'The snippet files to update',
+ required: false
+
def resolve(args)
snippet = authorized_find!(id: args.delete(:id))
result = ::Snippets::UpdateService.new(snippet.project,
- context[:current_user],
- args).execute(snippet)
+ context[:current_user],
+ update_params(args)).execute(snippet)
snippet = result.payload[:snippet]
{
@@ -47,7 +51,15 @@ module Mutations
private
def ability_name
- "update"
+ 'update'
+ end
+
+ def update_params(args)
+ args.tap do |update_args|
+ # We need to rename `files` into `snippet_actions` because
+ # it's the expected key param
+ update_args[:snippet_actions] = update_args.delete(:files)&.map(&:to_h)
+ end
end
end
end