debian-mirror-gitlab/app/graphql/mutations/environments/canary_ingress/update.rb

40 lines
1.1 KiB
Ruby
Raw Normal View History

2021-02-22 17:27:13 +05:30
# frozen_string_literal: true
module Mutations
module Environments
module CanaryIngress
class Update < ::Mutations::BaseMutation
graphql_name 'EnvironmentsCanaryIngressUpdate'
authorize :update_environment
argument :id,
::Types::GlobalIDType[::Environment],
required: true,
2021-10-27 15:23:28 +05:30
description: 'Global ID of the environment to update.'
2021-02-22 17:27:13 +05:30
argument :weight,
2021-10-27 15:23:28 +05:30
GraphQL::Types::Int,
2021-02-22 17:27:13 +05:30
required: true,
2021-10-27 15:23:28 +05:30
description: 'Weight of the Canary Ingress.'
2021-02-22 17:27:13 +05:30
def resolve(id:, **kwargs)
environment = authorized_find!(id: id)
result = ::Environments::CanaryIngress::UpdateService
.new(environment.project, current_user, kwargs)
.execute_async(environment)
{ errors: Array.wrap(result[:message]) }
end
def find_object(id:)
# TODO: remove as part of https://gitlab.com/gitlab-org/gitlab/-/issues/257883
id = ::Types::GlobalIDType[::Environment].coerce_isolated_input(id)
GitlabSchema.find_by_gid(id)
end
end
end
end
end