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

release_asset_link_type.rb « types « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 33dcb5125e370ff5b3acfd034f867b4d114b867a (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
31
32
33
# frozen_string_literal: true

module Types
  class ReleaseAssetLinkType < BaseObject
    graphql_name 'ReleaseAssetLink'
    description 'Represents an asset link associated with a release'

    authorize :read_release

    field :external, GraphQL::Types::Boolean, null: true, method: :external?,
          description: 'Indicates the link points to an external resource.'
    field :id, GraphQL::Types::ID, null: false,
          description: 'ID of the link.'
    field :link_type, Types::ReleaseAssetLinkTypeEnum, null: true,
          description: 'Type of the link: `other`, `runbook`, `image`, `package`; defaults to `other`.'
    field :name, GraphQL::Types::String, null: true,
          description: 'Name of the link.'
    field :url, GraphQL::Types::String, null: true,
          description: 'URL of the link.'

    field :direct_asset_path, GraphQL::Types::String, null: true, method: :filepath,
          description: 'Relative path for the direct asset link.'
    field :direct_asset_url, GraphQL::Types::String, null: true,
          description: 'Direct asset URL of the link.'

    def direct_asset_url
      return object.url unless object.filepath

      release = object.release.present
      release.download_url(object.filepath)
    end
  end
end