diff options
Diffstat (limited to 'app/graphql/types/ci/job_need_union.rb')
-rw-r--r-- | app/graphql/types/ci/job_need_union.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/app/graphql/types/ci/job_need_union.rb b/app/graphql/types/ci/job_need_union.rb new file mode 100644 index 00000000000..59608a6a312 --- /dev/null +++ b/app/graphql/types/ci/job_need_union.rb @@ -0,0 +1,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 |