Commit 254f78f5 authored by Luke Duncalfe's avatar Luke Duncalfe

Expose diff_refs on MergeRequestType

https://gitlab.com/gitlab-org/gitlab-ee/issues/9489
parent a00a23ca
# frozen_string_literal: true
module Types
# rubocop: disable Graphql/AuthorizeTypes
# Types that use DiffRefsType should have their own authorization
class DiffRefsType < BaseObject
graphql_name 'DiffRefs'
field :head_sha, GraphQL::STRING_TYPE, null: false, description: 'The sha of the head at the time the comment was made'
field :base_sha, GraphQL::STRING_TYPE, null: false, description: 'The merge base of the branch the comment was made on'
field :start_sha, GraphQL::STRING_TYPE, null: false, description: 'The sha of the branch being compared against'
end
# rubocop: enable Graphql/AuthorizeTypes
end
......@@ -23,6 +23,7 @@ module Types
field :updated_at, Types::TimeType, null: false
field :source_project, Types::ProjectType, null: true
field :target_project, Types::ProjectType, null: false
field :diff_refs, Types::DiffRefsType, null: true
# Alias for target_project
field :project, Types::ProjectType, null: false
field :project_id, GraphQL::INT_TYPE, null: false, method: :target_project_id
......
......@@ -5,11 +5,11 @@ module Types
# rubocop: disable Graphql/AuthorizeTypes
class DiffPositionBaseInputType < BaseInputObject
argument :head_sha, GraphQL::STRING_TYPE, required: true,
description: copy_field_description(Types::Notes::DiffPositionType, :head_sha)
description: copy_field_description(Types::DiffRefsType, :head_sha)
argument :base_sha, GraphQL::STRING_TYPE, required: false,
description: copy_field_description(Types::Notes::DiffPositionType, :base_sha)
description: copy_field_description(Types::DiffRefsType, :base_sha)
argument :start_sha, GraphQL::STRING_TYPE, required: true,
description: copy_field_description(Types::Notes::DiffPositionType, :start_sha)
description: copy_field_description(Types::DiffRefsType, :start_sha)
argument :paths,
Types::DiffPathsInputType,
......
......@@ -7,12 +7,7 @@ module Types
class DiffPositionType < BaseObject
graphql_name 'DiffPosition'
field :head_sha, GraphQL::STRING_TYPE, null: false,
description: "The sha of the head at the time the comment was made"
field :base_sha, GraphQL::STRING_TYPE, null: true,
description: "The merge base of the branch the comment was made on"
field :start_sha, GraphQL::STRING_TYPE, null: false,
description: "The sha of the branch being compared against"
field :diff_refs, Types::DiffRefsType, null: false
field :file_path, GraphQL::STRING_TYPE, null: false,
description: "The path of the file that was changed"
......
# frozen_string_literal: true
require 'spec_helper'
describe GitlabSchema.types['DiffRefs'] do
it { expect(described_class.graphql_name).to eq('DiffRefs') }
it { expect(described_class).to have_graphql_fields(:base_sha, :head_sha, :start_sha) }
end
......@@ -13,7 +13,7 @@ describe GitlabSchema.types['MergeRequest'] do
description_html state created_at updated_at source_project target_project
project project_id source_project_id target_project_id source_branch
target_branch work_in_progress merge_when_pipeline_succeeds diff_head_sha
merge_commit_sha user_notes_count should_remove_source_branch
merge_commit_sha user_notes_count should_remove_source_branch diff_refs
force_remove_source_branch merge_status in_progress_merge_commit_sha
merge_error allow_collaboration should_be_rebased rebase_commit_sha
rebase_in_progress merge_commit_message default_merge_commit_message
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe GitlabSchema.types['DiffPosition'] do
it 'exposes the expected fields' do
expected_fields = [:head_sha, :base_sha, :start_sha, :file_path, :old_path,
expected_fields = [:diff_refs, :file_path, :old_path,
:new_path, :position_type, :old_line, :new_line, :x, :y,
:width, :height]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment