Commit b99dc68a authored by charlie ablett's avatar charlie ablett

Merge branch 'ld-add-calls-gitaly-to-fields' into 'master'

GraphQL: Add missing calls_gitaly to some fields

See merge request gitlab-org/gitlab!47039
parents 13cdd3f8 d10ac87d
...@@ -10,7 +10,7 @@ module Types ...@@ -10,7 +10,7 @@ module Types
description: 'Default branch of the repository' description: 'Default branch of the repository'
field :empty, GraphQL::BOOLEAN_TYPE, null: false, method: :empty?, calls_gitaly: true, field :empty, GraphQL::BOOLEAN_TYPE, null: false, method: :empty?, calls_gitaly: true,
description: 'Indicates repository has no visible content' description: 'Indicates repository has no visible content'
field :exists, GraphQL::BOOLEAN_TYPE, null: false, method: :exists?, field :exists, GraphQL::BOOLEAN_TYPE, null: false, method: :exists?, calls_gitaly: true,
description: 'Indicates a corresponding Git repository exists on disk' description: 'Indicates a corresponding Git repository exists on disk'
field :tree, Types::Tree::TreeType, null: true, resolver: Resolvers::TreeResolver, calls_gitaly: true, field :tree, Types::Tree::TreeType, null: true, resolver: Resolvers::TreeResolver, calls_gitaly: true,
description: 'Tree of the repository' description: 'Tree of the repository'
......
---
title: Increase the complexity score of GraphQL MergeRequest#approved, MergeRequest#approvalsLeft
and Repository#exists fields as they can call Gitaly
merge_request: 47039
author:
type: changed
...@@ -6,9 +6,9 @@ module EE ...@@ -6,9 +6,9 @@ module EE
extend ActiveSupport::Concern extend ActiveSupport::Concern
prepended do prepended do
field :approved, GraphQL::BOOLEAN_TYPE, method: :approved?, null: false, field :approved, GraphQL::BOOLEAN_TYPE, method: :approved?, null: false, calls_gitaly: true,
description: 'Indicates if the merge request has all the required approvals. Returns true if no required approvals are configured.' description: 'Indicates if the merge request has all the required approvals. Returns true if no required approvals are configured.'
field :approvals_left, GraphQL::INT_TYPE, null: true, field :approvals_left, GraphQL::INT_TYPE, null: true, calls_gitaly: true,
description: 'Number of approvals left' description: 'Number of approvals left'
field :approvals_required, GraphQL::INT_TYPE, null: true, field :approvals_required, GraphQL::INT_TYPE, null: true,
description: 'Number of approvals required' description: 'Number of approvals required'
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe GitlabSchema.types['MergeRequest'] do
it { expect(described_class).to have_graphql_fields(:approvals_required, :merge_trains_count).at_least }
it { expect(described_class).to have_graphql_field(:approved, complexity: 2, calls_gitaly?: true) }
it { expect(described_class).to have_graphql_field(:approvals_left, complexity: 2, calls_gitaly?: true) }
end
...@@ -32,14 +32,7 @@ RSpec.describe GitlabSchema.types['MergeRequest'] do ...@@ -32,14 +32,7 @@ RSpec.describe GitlabSchema.types['MergeRequest'] do
has_ci mergeable commits_without_merge_commits squash security_auto_fix default_squash_commit_message has_ci mergeable commits_without_merge_commits squash security_auto_fix default_squash_commit_message
] ]
if Gitlab.ee? expect(described_class).to have_graphql_fields(*expected_fields).at_least
expected_fields << 'approved'
expected_fields << 'approvals_left'
expected_fields << 'approvals_required'
expected_fields << 'merge_trains_count'
end
expect(described_class).to have_graphql_fields(*expected_fields)
end end
describe '#pipelines' do describe '#pipelines' do
......
...@@ -10,4 +10,6 @@ RSpec.describe GitlabSchema.types['Repository'] do ...@@ -10,4 +10,6 @@ RSpec.describe GitlabSchema.types['Repository'] do
specify { expect(described_class).to have_graphql_field(:root_ref) } specify { expect(described_class).to have_graphql_field(:root_ref) }
specify { expect(described_class).to have_graphql_field(:tree) } specify { expect(described_class).to have_graphql_field(:tree) }
specify { expect(described_class).to have_graphql_field(:exists, calls_gitaly?: true, complexity: 2) }
end end
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