diff options
Diffstat (limited to 'app/graphql/mutations/saved_replies/base.rb')
-rw-r--r-- | app/graphql/mutations/saved_replies/base.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/app/graphql/mutations/saved_replies/base.rb b/app/graphql/mutations/saved_replies/base.rb new file mode 100644 index 00000000000..468263b0f9d --- /dev/null +++ b/app/graphql/mutations/saved_replies/base.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +module Mutations + module SavedReplies + class Base < BaseMutation + field :saved_reply, Types::SavedReplyType, + null: true, + description: 'Updated saved reply.' + + private + + def present_result(result) + if result.success? + { + saved_reply: result[:saved_reply], + errors: [] + } + else + { + saved_reply: nil, + errors: result.message + } + end + end + + def feature_enabled? + Feature.enabled?(:saved_replies, current_user, default_enabled: :yaml) + end + + def find_object(id) + # TODO: remove this line when the compatibility layer is removed + # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883 + id = ::Types::GlobalIDType[::Users::SavedReply].coerce_isolated_input(id) + + GitlabSchema.find_by_gid(id) + end + end + end +end |