Class: Mutations::ReleaseAssetLinks::Update

Inherits:
BaseMutation
  • Object
show all
Defined in:
app/graphql/mutations/release_asset_links/update.rb

Constant Summary collapse

ReleaseAssetLinkID =
::Types::GlobalIDType[::Releases::Link]

Constants inherited from BaseMutation

BaseMutation::ERROR_MESSAGE

Constants included from Gitlab::Graphql::Authorize::AuthorizeResource

Gitlab::Graphql::Authorize::AuthorizeResource::ConfigurationError, Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR

Instance Method Summary collapse

Methods inherited from BaseMutation

#api_user?, authorization, authorized?, authorizes_object?, #current_user, #errors_on_object, #load_application_object, #unauthorized_object

Methods included from Gitlab::Graphql::Authorize::AuthorizeResource

#authorize!, #authorized_find!, #authorized_resource?, #raise_resource_not_available_error!

Instance Method Details

#find_object(id) ⇒ Object


56
57
58
# File 'app/graphql/mutations/release_asset_links/update.rb', line 56

def find_object(id)
  GitlabSchema.find_by_gid(id)
end

#ready?(**args) ⇒ Boolean

Returns:

  • (Boolean)

37
38
39
40
41
42
43
44
# File 'app/graphql/mutations/release_asset_links/update.rb', line 37

def ready?(**args)
  if args.key?(:link_type) && args[:link_type].nil?
    raise Gitlab::Graphql::Errors::ArgumentError,
          'if the linkType argument is provided, it cannot be null'
  end

  super
end

#resolve(id:, **link_attrs) ⇒ Object


46
47
48
49
50
51
52
53
54
# File 'app/graphql/mutations/release_asset_links/update.rb', line 46

def resolve(id:, **link_attrs)
  link = authorized_find!(id)

  unless link.update(link_attrs)
    return { link: nil, errors: link.errors.full_messages }
  end

  { link: link, errors: [] }
end