summaryrefslogtreecommitdiff
path: root/app/graphql/types/commit_signature_interface.rb
blob: 6b0c16e538a9ba14c8a8e2d0f82af24ef1115263 (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
34
35
36
37
# frozen_string_literal: true

module Types
  module CommitSignatureInterface
    include Types::BaseInterface

    graphql_name 'CommitSignature'

    description 'Represents signing information for a commit'

    field :verification_status, CommitSignatures::VerificationStatusEnum,
                                null: true,
                                description: 'Indicates verification status of the associated key or certificate.'

    field :commit_sha, GraphQL::Types::String,
                       null: true,
                       description: 'SHA of the associated commit.'

    field :project, Types::ProjectType,
                    null: true,
                    description: 'Project of the associated commit.'

    orphan_types Types::CommitSignatures::GpgSignatureType,
                 Types::CommitSignatures::X509SignatureType

    def self.resolve_type(object, context)
      case object
      when ::CommitSignatures::GpgSignature
        Types::CommitSignatures::GpgSignatureType
      when ::CommitSignatures::X509CommitSignature
        Types::CommitSignatures::X509SignatureType
      else
        raise 'Unsupported commit signature type'
      end
    end
  end
end