Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/graphql/types/notes/discussion_type.rb')
-rw-r--r--app/graphql/types/notes/discussion_type.rb12
1 files changed, 7 insertions, 5 deletions
diff --git a/app/graphql/types/notes/discussion_type.rb b/app/graphql/types/notes/discussion_type.rb
index a51d253097d..9b863990849 100644
--- a/app/graphql/types/notes/discussion_type.rb
+++ b/app/graphql/types/notes/discussion_type.rb
@@ -3,24 +3,26 @@
module Types
module Notes
class DiscussionType < BaseObject
+ DiscussionID = ::Types::GlobalIDType[::Discussion]
+
graphql_name 'Discussion'
authorize :read_note
implements(Types::ResolvableInterface)
- field :id, GraphQL::ID_TYPE, null: false,
+ field :id, DiscussionID, null: false,
description: "ID of this discussion"
- field :reply_id, GraphQL::ID_TYPE, null: false,
+ field :reply_id, DiscussionID, null: false,
description: 'ID used to reply to this discussion'
field :created_at, Types::TimeType, null: false,
description: "Timestamp of the discussion's creation"
field :notes, Types::Notes::NoteType.connection_type, null: false,
description: 'All notes in the discussion'
- # The gem we use to generate Global IDs is hard-coded to work with
- # `id` properties. To generate a GID for the `reply_id` property,
- # we must use the ::Gitlab::GlobalId module.
+ # DiscussionID.coerce_result is suitable here, but will always mark this
+ # as being a 'Discussion'. Using `GlobalId.build` guarantees that we get
+ # the correct class, and that it matches `id`.
def reply_id
::Gitlab::GlobalId.build(object, id: object.reply_id)
end