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

job_need_union.rb « ci « types « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 59608a6a312ae18c65a166581af245c7fd9a8b93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

module Types
  module Ci
    class JobNeedUnion < GraphQL::Schema::Union
      TypeNotSupportedError = Class.new(StandardError)

      possible_types Types::Ci::JobType, Types::Ci::BuildNeedType

      def self.resolve_type(object, context)
        if object.is_a?(::Ci::BuildNeed)
          Types::Ci::BuildNeedType
        elsif object.is_a?(CommitStatus)
          Types::Ci::JobType
        else
          raise TypeNotSupportedError
        end
      end
    end
  end
end