Welcome to mirror list, hosted at ThFree Co, Russian Federation.

unpublish.rb « resources « catalog « ci « mutations « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e45e964614743557fc05fdcdb4ebb1a027ded895 (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
30
# frozen_string_literal: true

module Mutations
  module Ci
    module Catalog
      module Resources
        class Unpublish < BaseMutation
          graphql_name 'CatalogResourceUnpublish'

          authorize :add_catalog_resource

          argument :id, ::Types::GlobalIDType[::Ci::Catalog::Resource],
            required: true,
            description: 'Global ID of the catalog resource to unpublish.'

          def resolve(id:)
            catalog_resource = ::Gitlab::Graphql::Lazy.force(GitlabSchema.find_by_gid(id))
            authorize!(catalog_resource&.project)

            catalog_resource.unpublish!

            {
              errors: []
            }
          end
        end
      end
    end
  end
end