summaryrefslogtreecommitdiff
path: root/app/graphql/mutations/snippets/create.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/graphql/mutations/snippets/create.rb')
-rw-r--r--app/graphql/mutations/snippets/create.rb29
1 files changed, 17 insertions, 12 deletions
diff --git a/app/graphql/mutations/snippets/create.rb b/app/graphql/mutations/snippets/create.rb
index a8aeb15afcd..37c0f80310c 100644
--- a/app/graphql/mutations/snippets/create.rb
+++ b/app/graphql/mutations/snippets/create.rb
@@ -3,6 +3,7 @@
module Mutations
module Snippets
class Create < BaseMutation
+ include SpammableMutationFields
include ResolvesProject
graphql_name 'CreateSnippet'
@@ -56,10 +57,12 @@ module Mutations
::Gitlab::UsageDataCounters::EditorUniqueCounter.track_snippet_editor_edit_action(author: current_user)
end
- {
- snippet: service_response.success? ? snippet : nil,
- errors: errors_on_object(snippet)
- }
+ with_spam_fields(snippet) do
+ {
+ snippet: service_response.success? ? snippet : nil,
+ errors: errors_on_object(snippet)
+ }
+ end
end
private
@@ -81,14 +84,16 @@ module Mutations
end
def create_params(args)
- args.tap do |create_args|
- # We need to rename `blob_actions` into `snippet_actions` because
- # it's the expected key param
- create_args[:snippet_actions] = create_args.delete(:blob_actions)&.map(&:to_h)
-
- # We need to rename `uploaded_files` into `files` because
- # it's the expected key param
- create_args[:files] = create_args.delete(:uploaded_files)
+ with_spam_params do
+ args.tap do |create_args|
+ # We need to rename `blob_actions` into `snippet_actions` because
+ # it's the expected key param
+ create_args[:snippet_actions] = create_args.delete(:blob_actions)&.map(&:to_h)
+
+ # We need to rename `uploaded_files` into `files` because
+ # it's the expected key param
+ create_args[:files] = create_args.delete(:uploaded_files)
+ end
end
end
end