diff options
author | Luke Duncalfe <lduncalfe@eml.cc> | 2019-07-01 07:34:34 +0300 |
---|---|---|
committer | Luke Duncalfe <lduncalfe@eml.cc> | 2019-07-10 03:13:47 +0300 |
commit | a00a23ca828488ae343e02d8528bb94936d0e624 (patch) | |
tree | 8bf0228a3760133932ed666858a8121eaebc87c7 /app/graphql/mutations/notes/base.rb | |
parent | 42e876b7c01c61e74e3c7b0cb637ae43809ce1d2 (diff) |
GraphQL mutations for managing Notes
https://gitlab.com/gitlab-org/gitlab-ce/issues/62826
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 |