diff options
author | Marcel Amirault <mamirault@gitlab.com> | 2019-07-10 05:56:23 +0000 |
---|---|---|
committer | Marcel Amirault <mamirault@gitlab.com> | 2019-07-10 05:56:23 +0000 |
commit | 2b03a0c2cf699074ec37a863e5c752a2cab2b133 (patch) | |
tree | 7ebc289d2ec498fcebf8ae454cdb1eb1ef500dbd /app/graphql/mutations/notes/base.rb | |
parent | c0deda7a86796c5de6ebe376c83f55af0965bde3 (diff) | |
parent | 810df4fb51bf3db4016c5f7458599331d4586300 (diff) | |
download | gitlab-ce-2b03a0c2cf699074ec37a863e5c752a2cab2b133.tar.gz |
Merge branch 'master' into 'docs-hard-tabs'docs-hard-tabs
# Conflicts:
# doc/administration/pseudonymizer.md
# doc/administration/uploads.md
Diffstat (limited to 'app/graphql/mutations/notes/base.rb')
-rw-r--r-- | app/graphql/mutations/notes/base.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/app/graphql/mutations/notes/base.rb b/app/graphql/mutations/notes/base.rb new file mode 100644 index 00000000000..a7198f5fba6 --- /dev/null +++ b/app/graphql/mutations/notes/base.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module Mutations + module Notes + class Base < BaseMutation + include Gitlab::Graphql::Authorize::AuthorizeResource + + field :note, + Types::Notes::NoteType, + null: true, + description: 'The note after mutation' + + private + + def find_object(id:) + GitlabSchema.object_from_id(id) + end + + def check_object_is_noteable!(object) + unless object.is_a?(Noteable) + raise Gitlab::Graphql::Errors::ResourceNotAvailable, + 'Cannot add notes to this resource' + end + end + + def check_object_is_note!(object) + unless object.is_a?(Note) + raise Gitlab::Graphql::Errors::ResourceNotAvailable, + 'Resource is not a note' + end + end + end + end +end |