summaryrefslogtreecommitdiff
path: root/app/graphql/resolvers/design_management/version_resolver.rb
blob: 1bc9c1a7cd67cc035b9ff45494b00273bba4afd8 (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
  module DesignManagement
    class VersionResolver < BaseResolver
      include Gitlab::Graphql::Authorize::AuthorizeResource

      type Types::DesignManagement::VersionType, null: true

      authorize :read_design

      argument :id, ::Types::GlobalIDType[::DesignManagement::Version],
               required: true,
               description: 'The Global ID of the version'

      def resolve(id:)
        authorized_find!(id: id)
      end

      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[::DesignManagement::Version].coerce_isolated_input(id)

        GitlabSchema.find_by_gid(id)
      end
    end
  end
end