summaryrefslogtreecommitdiff
path: root/app/graphql/resolvers/work_items/types_resolver.rb
blob: 67a9d57d42f8379a73d33a3873816c417d482da9 (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
# frozen_string_literal: true

module Resolvers
  module WorkItems
    class TypesResolver < BaseResolver
      type Types::WorkItems::TypeType.connection_type, null: true

      argument :taskable, ::GraphQL::Types::Boolean,
               required: false,
               description: 'If `true`, only taskable work item types will be returned.' \
                            ' Argument is experimental and can be removed in the future without notice.'

      def resolve(taskable: nil)
        return unless Feature.enabled?(:work_items, object, default_enabled: :yaml)

        # This will require a finder in the future when groups/projects get their work item types
        # All groups/projects use the default types for now
        base_scope = ::WorkItems::Type.default
        base_scope = base_scope.by_type(:task) if taskable

        base_scope.order_by_name_asc
      end
    end
  end
end