summaryrefslogtreecommitdiff
path: root/app/graphql/resolvers/branch_commit_resolver.rb
blob: 11c49e17bc57a5a671bc80a87bf945749fc39901 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

module Resolvers
  class BranchCommitResolver < BaseResolver
    type Types::CommitType, null: true

    alias_method :branch, :object

    def resolve(**args)
      return unless branch

      commit = branch.dereferenced_target

      ::Commit.new(commit, context[:branch_project]) if commit
    end
  end
end