summaryrefslogtreecommitdiff
path: root/app/graphql/resolvers/work_item_resolver.rb
blob: 6eb23916d839430dd7000a4c950bcfe03acdb476 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

module Resolvers
  class WorkItemResolver < BaseResolver
    include Gitlab::Graphql::Authorize::AuthorizeResource

    authorize :read_work_item

    type Types::WorkItemType, null: true

    argument :id, ::Types::GlobalIDType[::WorkItem], required: true, description: 'Global ID of the work item.'

    def resolve(id:)
      work_item = authorized_find!(id: id)
      return unless Feature.enabled?(:work_items, work_item.project)

      work_item
    end

    private

    def find_object(id:)
      # TODO: remove this line when the compatibility layer is removed
      # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
      id = ::Types::GlobalIDType[::WorkItem].coerce_isolated_input(id)
      GitlabSchema.find_by_gid(id)
    end
  end
end