diff options
Diffstat (limited to 'app/graphql/mutations/notes/base.rb')
-rw-r--r-- | app/graphql/mutations/notes/base.rb | 32 |
1 files changed, 32 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..31dabc0a660 --- /dev/null +++ b/app/graphql/mutations/notes/base.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +module Mutations + module Notes + class Base < BaseMutation + 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 |