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/resolvers/work_item_resolver.rb')
-rw-r--r--app/graphql/resolvers/work_item_resolver.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/graphql/resolvers/work_item_resolver.rb b/app/graphql/resolvers/work_item_resolver.rb
new file mode 100644
index 00000000000..7cf52339815
--- /dev/null
+++ b/app/graphql/resolvers/work_item_resolver.rb
@@ -0,0 +1,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