gitlab-org--gitlab-foss/app/graphql/mutations/notes/base.rb
Luke Duncalfe 67030789f5 Include AuthorizeResource module for all mutations
This makes our authorization calls available to all GraphQL mutations
without the additional step of including the module first.
2019-07-11 15:08:34 +12:00

32 lines
755 B
Ruby

# 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