summaryrefslogtreecommitdiff
path: root/app/graphql/resolvers/release_resolver.rb
blob: 1edcc8c70b53bfd9e5a8458f1dac3024d8a9ce28 (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
# frozen_string_literal: true

module Resolvers
  class ReleaseResolver < BaseResolver
    type Types::ReleaseType, null: true

    argument :tag_name, GraphQL::STRING_TYPE,
            required: true,
            description: 'The name of the tag associated to the release'

    alias_method :project, :object

    def self.single
      self
    end

    def resolve(tag_name:)
      return unless Feature.enabled?(:graphql_release_data, project, default_enabled: true)

      ReleasesFinder.new(
        project,
        current_user,
        { tag: tag_name }
      ).execute.first
    end
  end
end