diff options
Diffstat (limited to 'app/graphql/types/notes/discussion_type.rb')
-rw-r--r-- | app/graphql/types/notes/discussion_type.rb | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/app/graphql/types/notes/discussion_type.rb b/app/graphql/types/notes/discussion_type.rb index a51d253097d..17cb4debd63 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, - description: "ID of this discussion" - field :reply_id, GraphQL::ID_TYPE, null: false, - description: 'ID used to reply to this discussion' + field :id, DiscussionID, null: false, + description: "ID of this discussion." + 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" + description: "Timestamp of the discussion's creation." field :notes, Types::Notes::NoteType.connection_type, null: false, - description: 'All notes in the discussion' + 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 |