diff options
Diffstat (limited to 'app/graphql/types/notes')
-rw-r--r-- | app/graphql/types/notes/discussion_type.rb | 12 | ||||
-rw-r--r-- | app/graphql/types/notes/note_type.rb | 2 |
2 files changed, 8 insertions, 6 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 diff --git a/app/graphql/types/notes/note_type.rb b/app/graphql/types/notes/note_type.rb index 84b61340e93..dea55fe7f9e 100644 --- a/app/graphql/types/notes/note_type.rb +++ b/app/graphql/types/notes/note_type.rb @@ -11,7 +11,7 @@ module Types implements(Types::ResolvableInterface) - field :id, GraphQL::ID_TYPE, null: false, + field :id, ::Types::GlobalIDType[::Note], null: false, description: 'ID of the note' field :project, Types::ProjectType, |