summaryrefslogtreecommitdiff
path: root/app/graphql/resolvers/work_item_resolver.rb
blob: 7cf523398159b44f70e1ddde6846ca21f15f54a9 (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, default_enabled: :yaml)

      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