summaryrefslogtreecommitdiff
path: root/app/graphql/types/notes/discussion_type.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/graphql/types/notes/discussion_type.rb')
-rw-r--r--app/graphql/types/notes/discussion_type.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/app/graphql/types/notes/discussion_type.rb b/app/graphql/types/notes/discussion_type.rb
index 17cb4debd63..56579c357a7 100644
--- a/app/graphql/types/notes/discussion_type.rb
+++ b/app/graphql/types/notes/discussion_type.rb
@@ -19,6 +19,8 @@ module Types
description: "Timestamp of the discussion's creation."
field :notes, Types::Notes::NoteType.connection_type, null: false,
description: 'All notes in the discussion.'
+ field :noteable, Types::NoteableType, null: true,
+ description: 'Object which the discussion belongs to.'
# DiscussionID.coerce_result is suitable here, but will always mark this
# as being a 'Discussion'. Using `GlobalId.build` guarantees that we get
@@ -26,6 +28,14 @@ module Types
def reply_id
::Gitlab::GlobalId.build(object, id: object.reply_id)
end
+
+ def noteable
+ noteable = object.noteable
+
+ return unless Ability.allowed?(context[:current_user], :"read_#{noteable.to_ability_name}", noteable)
+
+ noteable
+ end
end
end
end